Relational Algebra (Union Operation)

Neso Academy
7 Nov 202220:15

Summary

TLDRThis video script focuses on the Union operation in relational algebra, one of the six fundamental operations. It explains that Union is a binary operation, combining two relations without duplicate tuples. The script uses examples to demonstrate how Union works, emphasizing the need for compatible relations with the same number of attributes and domains. It also introduces the University database schema and poses homework questions to practice the concept.

Takeaways

  • 😀 Relational algebra's Union operation combines tuples from two relations into a single set, eliminating duplicates.
  • 🔑 The Union operation is a binary operator, requiring two inputs (relations) to perform.
  • 📚 Union in relational algebra mirrors the set theory's union operation, focusing on combining sets of tuples.
  • 🍎 Example given: Union of relations containing fruits results in a unique set of fruits, with duplicates like 'apple' appearing only once.
  • 📐 To perform a Union, both relations must have the same number of attributes (arity) and corresponding domains must match.
  • 📝 The script introduces the concept with a simple example using single-attribute relations and progresses to more complex scenarios.
  • 🏫 The script uses a university database schema to demonstrate how to find customer names associated with a bank as either account holders or loan borrowers.
  • 🌐 It explains the importance of projection before Union when dealing with relations that have multiple attributes.
  • 📈 The script also covers how to find all courses taught in specific semesters using the Union operation.
  • 🎓 Homework questions are provided to practice finding course IDs and instructor IDs for specific semesters using the Union operation.

Q & A

  • What is the Union operation in relational algebra?

    -The Union operation in relational algebra is an operation that combines two relations (tables) into a single relation containing all distinct rows from the input relations. It is similar to the union operation in set theory.

  • Is the Union operation a unary or binary operator?

    -The Union operation is a binary operator because it requires at least two tables to perform the operation.

  • What is the purpose of eliminating duplicate values in the Union operation?

    -Duplicate values are eliminated in the Union operation to ensure that each row (tuple) appears only once in the resultant relation, maintaining the set nature of relations in DBMS.

  • What symbol is used to denote the Union operation?

    -The symbol used to denote the Union operation is the union symbol, which is represented by the word 'Union' or the symbol '∪'.

  • What are the conditions that must be met before performing a Union operation on two relations?

    -To perform a Union operation, the two relations must have the same number of attributes, and the corresponding attributes must be of the same domain.

  • Can you perform a Union operation directly on two different relations with different numbers of attributes?

    -No, you cannot directly perform a Union operation on two relations with different numbers of attributes. The relations must be compatible in terms of the number of attributes and the domain of each attribute.

  • How does the Union operation handle duplicate rows when combining two relations?

    -The Union operation eliminates duplicate rows when combining two relations, ensuring that each row appears only once in the resulting relation.

  • What is the difference between the Union operation and the Project operation in relational algebra?

    -The Union operation combines two relations into one by including all distinct rows from both, while the Project operation selects specific columns from a relation and creates a new relation with only those columns.

  • Can you provide an example of how the Union operation works with two relations?

    -Sure. If you have two relations, one with fruits like 'apple', 'mango', and 'grapes', and another with 'apple', 'strawberry', when you perform a Union operation, the result will be a relation with 'apple', 'mango', 'grapes', and 'strawberry', with 'apple' only appearing once.

  • What is the significance of the projection operation in the context of the Union operation?

    -The projection operation is often used in conjunction with the Union operation to ensure that only the relevant attributes are considered for the Union. This helps in aligning the relations to have the same schema before performing the Union.

  • How does the Union operation relate to the concept of sets in mathematics?

    -The Union operation in relational algebra is closely related to the concept of sets in mathematics. It follows the set theory principle of combining two sets into a single set that contains all the distinct elements from both sets.

Outlines

00:00

📚 Introduction to Union Operation in Relational Algebra

The paragraph introduces the concept of the Union operation in relational algebra, which is the third fundamental operation after select and project. It explains that a relation in a database management system (DBMS) is akin to a set in mathematics, and the Union operation combines two relations into a single set of tuples without duplicates. The Union operator is a binary operator, requiring two inputs, and the output is a set containing all tuples from both relations. An example is provided to illustrate how duplicates are eliminated, such as combining a list of fruits from two sets into a single list without repeating any fruit. The paragraph also discusses the syntax and conditions required for performing a Union operation, emphasizing that the relations must have the same number of attributes and compatible domains for the attributes.

05:01

🔗 Applying Union Operation with Simple Examples

This paragraph demonstrates the Union operation with a simple example using two relations, R and Yes, which both have a single attribute. It explains the conditions required for the Union operation, such as having the same number of attributes and compatible domains for each attribute. The example shows how the Union of R and Yes results in a new relation that includes all unique values from both relations. The paragraph also discusses a practical scenario where the Union operation is used to list customer names associated with a bank as either account holders or loan borrowers, emphasizing the use of projection before applying the Union to ensure the relations have compatible structures.

10:02

📈 Projection and Union in Relational Algebra

The paragraph continues the discussion on the Union operation by explaining how it is applied in conjunction with projection. It uses an example of finding all courses taught in specific semesters by first selecting the relevant courses from a 'section' relation and then projecting the course IDs. The example illustrates how to retrieve and combine data from a database using relational algebra operations. The paragraph also introduces the concept of making assumptions about table names when they are not explicitly mentioned and proceeds with expressions to understand the operation clearly.

15:05

🏫 Union Operation in the Context of University Database

This paragraph applies the Union operation in the context of a university database schema. It presents a scenario where the goal is to find all courses taught in specific semesters by using the 'section' relation. The paragraph explains how to perform a select operation to filter the courses by semester and year, followed by a projection to retrieve only the course IDs. The Union operation is then used to combine the results from different semesters into a single set of course IDs. The paragraph concludes with a discussion of two homework questions that involve using the Union operation to solve practical database queries, emphasizing the importance of understanding relational algebra for competitive examinations.

Mindmap

Keywords

💡Relational Algebra

Relational algebra is a theory that deals with mathematical operations performed on relations (which in this context are similar to tables in a database). It is a fundamental concept in database management systems (DBMS). The video script focuses on explaining various operations within relational algebra, specifically the union operation. This concept is foundational to understanding how data can be manipulated and retrieved from a database.

💡Union Operation

The union operation in relational algebra combines two relations into a single one, containing all the tuples from both relations without duplicates. It is likened to the union operation in set theory. In the script, the union operation is the main focus of the lecture, with examples provided to illustrate how it works, such as combining a list of fruits from two different sets.

💡Binary Operator

A binary operator is an operation that takes two operands to produce a result. In the context of the video, the union operation is described as a binary operator because it requires two relations (tables) as input to perform the union. The script explains that the union operator is not unary (single input) but binary, necessitating at least two tables.

💡Duplicate Values

Duplicate values refer to the occurrence of the same data point more than once. The script clarifies that the union operation in relational algebra, much like the project operation, eliminates duplicate rows. This ensures that the resultant relation only contains unique tuples, even if the original relations had overlapping data.

💡Projection Operation

The projection operation is one of the fundamental operations in relational algebra that creates a new relation with a subset of attributes from an existing relation. The script mentions the projection operation in the context of preparing data for the union operation, where only certain columns (attributes) from relations are selected before performing the union.

💡Set Theory

Set theory is a branch of mathematical logic that studies sets, which are collections of distinct objects. The script draws a parallel between the union operation in relational algebra and the union operation in set theory, emphasizing the concept of combining sets without duplicate elements, which is a key principle in both areas.

💡Relation

In the context of the video, a relation is analogous to a table in a relational database and is treated as a set in mathematical terms. The script explains that any relation in a DBMS corresponds closely with the mathematical concept of a set, which is why operations like union can be applied.

💡Attributes

Attributes in a relation (table) are the columns that define the properties of the tuples (rows). The script discusses the importance of having the same number of attributes in two relations before they can be unioned. It also mentions that the domain (type of data) of corresponding attributes must match.

💡Domain

The domain of an attribute refers to the set of possible values that the attribute can take. The script explains that for the union operation to be valid, the domain of the ith attribute in one relation must be the same as that in the other relation. This ensures compatibility between the attributes of the two relations being unioned.

💡Schema

A schema is a blueprint that defines the structure of a database, including the relations, attributes, and types of data each attribute can contain. The script suggests pausing to consider the schema when dealing with database queries, which is crucial for understanding how data is organized and how operations like union can be applied.

💡Example Relations

Example relations are hypothetical sets of data used to illustrate how database operations work. The script uses example relations such as 'depositor' and 'borrower' to demonstrate the union operation, helping viewers understand how to apply these operations to real-world data scenarios.

Highlights

Introduction to the Union operation in relational algebra

Union operation is similar to the union operation in set theory

Union operation requires at least two tables

Union operator is a binary operator

Output of Union operation contains members from both relations without duplicates

Example of Union operation with lists of fruits

Symbol used to denote the Union operation

Union cannot be directly applied on two different relations

Union operation requires the relations to have the same number of attributes

Projection operation is often used before Union

Simple example of Union operation with alphabets

Formal example of Union operation with customer names

Union operation is used to find customer names associated with the bank as account holders or loan borrowers

Example of Union operation with courses taught in different semesters

Two important conditions for performing Union operation

Condition 1: Relations must have the same number of columns

Condition 2: Domain of corresponding attributes must be the same

Homework questions related to Union operation

Next presentation will focus on the set difference operation

Transcripts

play00:00

foreign

play00:06

we will see the next relational algebra

play00:10

fundamental operation the relational

play00:12

algebra Union operation we know

play00:15

basically there are six fundamental

play00:17

relational algebra operations and we

play00:20

have already seen about the first two

play00:21

operations the select and project

play00:23

operations in the previous lectures now

play00:26

we are going to focus on the third

play00:27

fundamental operation which is the union

play00:30

operation let's see the theoretical

play00:32

aspects of this Union operation now and

play00:35

we have already seen this point in the

play00:37

last presentation that any relation is a

play00:40

set a relation in dbms is having a close

play00:43

correspondence or close association with

play00:45

the mathematical concept called the set

play00:47

and when we talk about the union

play00:49

operation in relational algebra this

play00:52

Union operation is similar to the union

play00:54

operation in the set theory and that's

play00:57

why I told you any relation is a set and

play01:00

this Union operation what we are

play01:01

focusing on in this presentation is

play01:04

similar to the union operation a insert

play01:07

Theory and what type of operator is this

play01:09

Union operator is it a unary or a binary

play01:11

operator the name itself says that it is

play01:14

going to do the union operation it means

play01:16

it requires at least two tables to

play01:18

perform the operation isn't it so it is

play01:21

a binary operator where it requires two

play01:24

inputs to be precise it requires two

play01:27

tables or two relations to perform the

play01:29

operation say we have two relations A

play01:32

and B and what's the output of a union B

play01:35

that's what we are going to see now it

play01:37

is a set of all objects that are a

play01:40

member of a or b or both if we take a as

play01:45

a relation and B as another relation and

play01:48

we perform a union B then the output is

play01:51

going to be the set of all objects or

play01:54

all tuples that are a member of a or b

play01:58

or both no worries when we see an

play02:01

example at the time it will be easy to

play02:03

understand but for now just understand

play02:05

when we are are performing a union B the

play02:08

output will be containing the members

play02:10

from a as well as the members from B and

play02:13

there are situations where the values

play02:15

may be appearing in both A and B will we

play02:17

be having duplicate values no we will

play02:20

not be having duplicate values so like

play02:22

the project operation here also the

play02:25

duplicate rows are eliminated let's say

play02:27

a is containing some list of fruits say

play02:30

for example apple mango and grapes and B

play02:33

contains apple and strawberry and when

play02:35

we perform EA Union B we will be getting

play02:37

Apple only once why even though the

play02:41

fruit apple is in both the sets A and B

play02:43

but still we will be getting only one

play02:46

apple in the resultant and that's why I

play02:48

told you the values in the output will

play02:50

be the member of a or b or even both but

play02:54

if there are duplicate values these

play02:56

duplicate values are eliminated in The

play02:58

resultant table and what is the symbol

play03:00

which is used to denote the union

play03:02

operation this is the symbol the union

play03:04

symbol which is used to denote the union

play03:07

operation let's see the syntax now when

play03:10

we talk about Union we cannot directly

play03:13

apply Union on two different relations

play03:15

let's say a is a relation and b is

play03:18

another relation can we directly perform

play03:20

a union B we need to ensure certain

play03:23

conditions are met because we cannot

play03:26

directly perform a union B the number of

play03:28

attributes in EA may be different from

play03:31

the number of attributes in B say for

play03:33

example if a contains five attributes

play03:36

and B contains four attributes in this

play03:38

case a union B cannot be performed then

play03:41

how it will be helpful just see the

play03:43

syntax it will be easy we are not

play03:46

directly performing relation One Union

play03:48

relation to rather we are performing the

play03:51

projection of a single column or

play03:53

multiple columns from relation one that

play03:56

is performed with the union with another

play03:59

projection it may be a single column or

play04:01

a group of columns from another relation

play04:03

which is relation 2 in this example so

play04:06

what we are actually doing here is we

play04:08

are going to project a column from

play04:10

relation 1 Union and we are going to

play04:13

project another column from relation to

play04:15

and the output of this will be single

play04:18

column and the output of this will be

play04:20

single column and we are going to

play04:21

perform form one column Union another

play04:24

column remember the output of this will

play04:26

be a relation only and the output of

play04:28

this is also going to be a relation only

play04:30

so we are going to perform Union between

play04:32

relations but not directly when we see

play04:35

an example we will be able to understand

play04:37

things clearly let's first understand

play04:40

the operation of Union with simple

play04:42

example

play04:44

let's say we have a relation R which

play04:47

contain only one attribute and this

play04:49

attribute is alphabets a b c e and f

play04:53

let's take another relation which is yes

play04:56

and this relation is having a column or

play04:58

an attribute which is characters and the

play05:00

characters are a b dollar e f 1 and hash

play05:06

symbol now what we are going to perform

play05:08

is R Union Yes can we do our Union Yes

play05:12

yes there are certain conditions to be

play05:14

made but at the basic level the first

play05:16

condition will be satisfied the number

play05:18

of attributes in R is same as that of

play05:21

the number of attributes in yes so here

play05:23

also we have only one attribute in the

play05:25

relation here also we have only one

play05:27

attribute in the relation so our Union

play05:29

Yes can be performed but still we have

play05:31

another condition to be satisfied before

play05:33

applying Union which we will see at the

play05:36

end of this presentation for now just

play05:38

understand I am going to apply R Union

play05:40

yes let's see the output of our Union

play05:43

Yes and the output is going to be our

play05:46

Union is let's see what's the data

play05:48

present in this our Union s relation say

play05:51

a b c e f so all these value will appear

play05:55

in the output relation a b c e and f now

play05:59

the members of R is present all the

play06:02

members of R is present in the output

play06:04

relation now we need to ensure whether

play06:06

all the members of Yes are also present

play06:08

in the output relation talking about the

play06:10

first member a which is already already

play06:12

there in the output relation as per the

play06:14

concept of uni and the duplicate values

play06:16

are eliminated so this a will not be

play06:19

appearing again in this output relation

play06:21

likewise B Because B is also already

play06:24

there in the output relation and talking

play06:26

about dollar dollar is not there in R

play06:29

but it is there in yes so dollar will be

play06:32

there in the output relation coming to e

play06:34

and f e and f are already there in R

play06:37

which is already sent to the output R

play06:39

Union Yes I mean which is already

play06:41

available in the output relation so E

play06:44

and F will not be appearing again

play06:45

because it's a duplicate value now so

play06:48

this will be eliminated then coming to 1

play06:50

if you see one is there only in yes and

play06:53

not in R so one will also be there in

play06:55

the output and coming to the hash symbol

play06:58

this hash symbol is not available in the

play07:00

relation R but available in s so this

play07:03

will also be available in the output

play07:05

table so this is the working of R Union

play07:08

s in simple terms if we consider two

play07:11

relations r is the output will be

play07:14

containing the members of r or the

play07:17

members of Yes or both so this example

play07:19

is just for understanding Purpose with

play07:22

this knowledge let's see the formal

play07:23

example

play07:25

the question is list all customer names

play07:28

associated with the bank either as an

play07:31

account holder or a loan borrower just

play07:34

pause this video for a while and think

play07:36

what are the two relations that we are

play07:38

talking about in this question

play07:40

I hope you are done the example

play07:43

relations that we are talking here is

play07:45

one is related to the account holder and

play07:48

the other one is related to the loan so

play07:50

what we are assuming here is there are

play07:52

two relations one is the deposited

play07:54

relation so I am saying if somebody is

play07:57

having an account in the bank it means

play07:59

that person is having a deposited

play08:01

relationship with the bank so here is

play08:03

the depositor relation and if somebody

play08:05

has awailed a loan from the bank so

play08:08

obviously he is a borrower right so he

play08:10

is the loan borrower so I am considering

play08:12

these two relations are existing number

play08:15

one the depositor and number two the

play08:18

borrower and what we are required to

play08:19

find we are required to find the list of

play08:22

all customer names associated with the

play08:25

bank either as an account holder or as a

play08:28

loan borrower let's say there is a

play08:30

customer X if that name X it should

play08:33

appear either in the account relation or

play08:35

in the depository relation it may even

play08:37

appear in both the relations but our

play08:40

output should contain the value X

play08:42

let's solve this problem now so what we

play08:44

are doing is we are considering this

play08:46

depositor relation and we are retrieving

play08:49

only customer name from the depositor

play08:51

relation which is this part

play08:53

so all the depositor's name will be

play08:55

appearing here just see what operator I

play08:57

have used the project operator so this

play09:00

project retrieves only the customer

play09:02

names from this depositor relation and

play09:04

the output of this is going to be a

play09:06

relation a temporary relation which

play09:09

contains only one attribute which is

play09:11

customer name and coming to this side

play09:13

here I am focusing on the borrower

play09:15

relation and in the borrower relation I

play09:17

am retrieving only the customer names

play09:19

from the borrower table or borrower

play09:21

relation and here what operator I am

play09:23

using the same project operator please

play09:26

note the depositor relation may contain

play09:28

X number of attributes and the borrow

play09:30

relation may contain y number of

play09:32

attributes Y and X may not be the same

play09:34

but here we are not doing depositor

play09:37

Union borrower we are doing customer

play09:40

name Union customer name only where this

play09:43

customer name is from depositor relation

play09:45

and this customer name is from borrower

play09:47

relation and the output of this

play09:49

expression is going to be a table with

play09:51

only one attribute and the o output of

play09:53

this expression is going to be only one

play09:55

relation with one attribute and we can

play09:57

perform Union

play09:59

so here is the output for this query so

play10:02

generally when questions are asked just

play10:04

make an assumption what could be the

play10:05

table name and just start proceeding

play10:07

with the expression if table names are

play10:09

not explicitly mentioned we can make

play10:11

assumptions on the table name and we can

play10:13

proceed with the Expressions to

play10:15

understand things clearly let me

play10:17

elaborate the solution with an example

play10:19

table let's take this is the depositor

play10:21

table which contains two attributes

play10:23

customer name and account number which

play10:25

is this relation let's take this

play10:27

relation the borrower relation which

play10:29

contains two attributes customer name

play10:31

and loan number are we going to do

play10:33

depositor Union borrower depositor Union

play10:36

borrower may be proceeded with because

play10:38

it also has two attributes and this also

play10:40

has two attributes but still we have

play10:42

other conditions to be checked before

play10:44

proceeding with depositor Union borrower

play10:46

let's not touch upon that part now but

play10:49

for now just understand we are not going

play10:51

to proceed with the Positive Union

play10:52

borrower rather we are going to proceed

play10:55

with projection of customer name from

play10:57

depositor Union projecting customer name

play11:00

from borrower it means I am going to do

play11:02

Union only for these two columns this

play11:05

one Union this one let me give a naming

play11:08

convention for easy readability let this

play11:11

be R and let this be yes so what is r

play11:14

it's the customer name from depositor

play11:16

relation so what I am doing is I am just

play11:18

renaming this output as R which is this

play11:20

so This R contains only the customer

play11:22

names from depositor relation and this s

play11:25

contains the customer name only from

play11:28

borrower relation and this is R this is

play11:30

s so what I'm gonna perform is R Union

play11:33

Yes which is the customer name so Tom

play11:36

Amy Rose John Tom Amy Rose John it's

play11:41

appearing here then coming to this place

play11:43

John John is already there in the table

play11:46

so this will be ignored this will be

play11:49

eliminated because this is a duplicate

play11:51

value coming to Smith Smith is not there

play11:53

already in the output table so Smith

play11:55

will be added coming to rows Rose is

play11:58

already there in the output table so

play11:59

rows will also be eliminated and coming

play12:02

to Jack Jack is not already there in the

play12:04

output table in other words jack is not

play12:06

there in the first table and hence Jack

play12:08

will be added to the output and this is

play12:11

the output of R Union Yes

play12:14

before seeing the other example I will

play12:16

show you the schema

play12:18

just pause this video for a while and

play12:20

have a look at the schema

play12:23

I hope you all done now let's proceed

play12:26

with the next example the question is

play12:29

find the set of all courses taught in

play12:32

the fall 2009 semester the spring 2010

play12:35

semester or both

play12:37

what we are required to find we are

play12:39

required to find the set of all courses

play12:42

and these courses may be taught either

play12:44

in Fall 2009 semester or in the spring

play12:47

2010 semester or both now from which

play12:51

table we need to perform all this

play12:52

operation if you want I'll just show you

play12:54

the table just think about it

play12:57

so from which relation we are going to

play12:58

retrieve the data

play13:00

section is the relation where this

play13:03

contains the course as well as the

play13:05

semester as well as the year which has

play13:07

been taught right so I am going to take

play13:09

the list of all courses that are taught

play13:12

in this particular semester and in this

play13:15

particular Year from this relation

play13:16

section

play13:19

so the answer for this part is going to

play13:21

be the project operation and before that

play13:24

what we need to do from the section

play13:26

relation we are going to retrieve all

play13:28

the courses that are taught in the

play13:31

semester fall and in the year 2009 so

play13:34

what I am doing is first I am retrieving

play13:36

all the tuples where the semester is

play13:39

fall and giving and condition because in

play13:42

this form and 2009 year so I am

play13:45

selecting all the tuples where the

play13:47

semester is fall and the year is 2009

play13:50

from the section relation so this will

play13:52

give all the tuples and what I need only

play13:55

the set of all courses right so course

play13:58

ID I need the course ID so I'm just

play14:00

projecting only course ID from this

play14:02

output temporary relation remember this

play14:05

temporary relation will contain the set

play14:07

of all tuples with all attributes from

play14:10

those attributes I am retrieving only

play14:11

course ID

play14:13

so this is for this semester fall 2009

play14:16

we need to do the same for spring 2010

play14:18

so the query goes like this to find the

play14:21

set of all courses taught in the spring

play14:22

2010 semester we write select semester

play14:26

is equal to spring because we are

play14:28

focusing on this part and here is equal

play14:31

to 2010 and year is equal to 2010 from

play14:34

the section relation the output of this

play14:37

inner query is going to be a temporary

play14:39

relation with the tuples with all

play14:41

attributes and from this I am going to

play14:43

project only one attribute which is

play14:45

course side now this query gives the

play14:48

output of all the course ID that is dot

play14:51

in Fall 2009 this query gives the output

play14:54

of all course ID that are taught in

play14:56

Spring 2010 and what's the question we

play15:00

need to list all the courses that are

play15:02

taught in Fall 2009 spring 2010 or both

play15:05

in that case to answer this query we

play15:08

need the union of these two sets so the

play15:11

output of this is this part which is

play15:13

this part Union this part which is this

play15:17

so the output is going to be the set of

play15:20

all courses taught in Fall 2009 semester

play15:23

the spring 2010 semester or both before

play15:27

we sign out let's see the two important

play15:29

conditions to be valid for performing

play15:31

the union between two tables

play15:34

the two important conditions for what

play15:37

for our Union Yes to be valid

play15:40

I mean r is a relation here and S is a

play15:43

relation here for our Union Yes to be

play15:46

valid then these two conditions should

play15:48

be met first R and S must be of same r80

play15:51

what do we mean by this it means the

play15:54

number of columns in R and the number of

play15:56

columns in yes must be the same

play15:59

in simple terms the number of columns in

play16:02

both the relations R and S should be the

play16:04

same for example if the relation R

play16:06

contains 10 attribute and the relation s

play16:09

contains five attributes R Union Yes is

play16:12

not possible because the first condition

play16:14

itself is the number of attributes on R

play16:17

and S must be the same

play16:19

let's say if the number of attributes

play16:21

are matching

play16:22

then can we directly perform R Union Yes

play16:24

No we cannot directly perform R Union

play16:26

yes so the next condition is for all I

play16:30

the domain of the ith attribute of R

play16:32

should be the same as that of the domain

play16:35

of ith attribute of yes

play16:37

what do we mean by this let's say there

play16:40

are two relations R and S and R contains

play16:43

three attributes and S also contains

play16:45

three attributes so the first condition

play16:47

is satisfied both R and S must be of

play16:49

same rity yes R and S has three columns

play16:53

each and coming to the second condition

play16:55

the domain of ith attribute of R should

play16:58

be the same as that of the domain of ith

play17:01

attribute of yes

play17:03

it means the domain of the first

play17:05

attribute of the relation R should be

play17:07

the same as that of the domain of the

play17:09

first attribute of yes the domain of the

play17:12

second attribute of the relation R

play17:14

should be the same as that of the domain

play17:16

of the second attribute of the relation

play17:18

yes so likewise all the attributes

play17:21

according to their position should be

play17:23

belonging to the same domain when these

play17:25

two conditions are made R Union s is

play17:28

possible but in our example we have not

play17:31

simply performed Union between two

play17:33

relations directly rather we have

play17:35

projected the output the temporary

play17:37

output and then we perform the union

play17:38

among these two outputs

play17:41

and that's it guys before we sign out

play17:43

let's see the homework questions here we

play17:46

have two homework questions let's see

play17:48

what are they before seeing the

play17:50

questions I wanted to introduce the

play17:51

schema that we are familiar with this is

play17:54

the University database schema where we

play17:57

have multiple relations instructor

play17:59

course Department section teachers

play18:02

student advisor takes classroom and time

play18:07

slot question number one which is list

play18:10

all the course IDs which are taken in

play18:13

Spring 2020 or fall 2021 semester so

play18:17

this is a pretty straightforward

play18:19

question because we are going to find

play18:20

all the course IDs which are taken in

play18:24

spring semester year 2020 or fall

play18:27

semester year 2021

play18:29

we can easily answer this question

play18:31

number one because it's a simple

play18:33

projection along with Union only thing

play18:36

is we are required to find the right

play18:37

table or the right relation and the

play18:39

right attributes for the condition

play18:41

spring 2020 or fall 2021

play18:44

and coming to question number two list

play18:46

all the instructors ID who taught

play18:49

courses in Spring 2020 or fall 2021 and

play18:54

question number two is a bit tricky

play18:55

question because we are required to find

play18:57

all the instructor IDs but the tricky

play19:00

part is the instructor's ID are

play19:02

available in multiple relations can you

play19:04

see here this instructor relation also

play19:06

has ID and coming to teachers relation

play19:09

this also has ID and coming to advisor

play19:12

relation this also has ID I am not

play19:14

bothering about this because this ID

play19:15

represents student so what I mean to say

play19:18

here is we have instructors ID in

play19:20

multiple relations and the challenge is

play19:22

to find the appropriate table that

play19:25

contains the information about the

play19:27

courses that the instructor has thought

play19:29

in Spring 2020 semester or fall 2021

play19:33

semester I request you to meticulously

play19:35

look into the questions and post your

play19:37

answers in the comment section and these

play19:40

kind of questions will definitely help

play19:41

us to crack the competitive examination

play19:43

questions

play19:44

and that's it guys in today's

play19:46

presentation we have focused on the

play19:48

union operation in relational algebra in

play19:51

the next presentation we will focus on

play19:53

the set difference operation which is

play19:54

also one of the important operations in

play19:57

relational algebra and that's it guys I

play20:00

hope you guys enjoyed this presentation

play20:01

and thank you for watching

play20:04

[Music]

play20:04

[Applause]

play20:06

[Music]

Rate This

5.0 / 5 (0 votes)

相关标签
Relational AlgebraDatabase ManagementUnion OperationSet TheoryData RetrievalSQL QueriesData AnalysisEducational ContentTutorial VideoDatabase Schema
您是否需要英文摘要?