0% found this document useful (0 votes)
20 views3 pages

Class Exercises Relational Algebra - Solution

Uploaded by

nkocienkosenhle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

Class Exercises Relational Algebra - Solution

Uploaded by

nkocienkosenhle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

INFM201- Relational Set Operators Exercises

1. Create a table that results from applying a UNION to the tables shown below.

Table A
C1 001
C2 004
C3 006
C4 007

Table B
C2 004
C3 006
C5 008
C6 009

UNION of A and B

C1 001
C2 004
C3 006
C4 007
C5 008
C6 009

2. Create a table that results from applying a INTERSECT to the tables shown below.

Table S
Pam
Lionel
John

Table T
Harvey
John
Anne

Intersection of S and T
John

3. Create a table that results from applying a DIFFERENCE to the tables shown below.
Table S Table T

Pam Harvey
Lionel John
John Anne

Difference of S and T
Pam
Lionel
4. Consider Figure 1 below and answer questions that follow.

Table 1: EMPLOYEEBIO Table 2: EMPLOYEEJOB


EMP_NUM EMP_NAME EMP_AGE EMP_ADDR JOBNUM POSITION SALARY EMP_ID
16 Panther
11522 Pink Panther 35 Crescent 501 Editor 35000 11533
11533 Tinker Bell 21 5 Sunshine Avenue 522 Script Writer 25000 11544
11544 Knight Rider 18 10 Disney World 525 Director 85000 11566
11555 Mickey Mouse 30 7 Mouse Drive 575 Photographer 30000 11522
11566 Tom Cat 22 1 Wall Street 565 Animator 70000 11599
11577 Ben Ten 19 101 Dream Street 535 Sound Engineer 75000 11500
11588 Silver Star 25 15 Fame Street

Figure 1: Work Database Tables

4.1 Identify the primary keys and foreign keys for the tables in Figure 1.

EMP_NUM is the EMPLOYEEBIO table's primary key.


JOB_NUM is the EMPLOYEEJOB table's primary key.
The foreign key is EMP_ID, located in the EMPLOYEEJOB table.

4.2 Create a table that results from applying a NATURAL JOIN to the tables
shown in Figure 1 above.

NATURAL JOIN
EMP_NUM EMP_NAME EMP_AGE EMP_ADDR JOBNUM POSITION SALARY EMP_NUM
16 Panther
11522 Pink Panther 35 Crescent 575 Photographer 30000 11522
11533 Tinker Bell 21 5 Sunshine Avenue 501 Editor 35000 11533
11544 Knight Rider 18 10 Disney World 522 Script Writer 25000 11544
11566 Tom Cat 22 1 Wall Street 525 Director 85000 11566

4.3 Create a table that results from applying a RIGHT OUTER JOIN to the tables
shown in Figure 1 above.

RIGHT OUTER JOIN


EMP_NUM EMP_NAME EMP_AGE EMP_ADDR JOBNUM POSITION SALARY EMP_NUM
Pink
11522 Panther 35 16 Panther Crescent 575 Photographer 30000 11522
11533 Tinker Bell 21 5 Sunshine Avenue 501 Editor 35000 11533
11544 Knight Rider 18 10 Disney World 522 Script Writer 25000 11544
11566 Tom Cat 22 1 Wall Street 525 Director 85000 11566
Null Null Null Null 565 Animator 70000 11599
Sound
Null Null Null Null 535 Engineer 75000 11500
4.4 Create a table that results from applying a LEFT OUTER JOIN to the tables
shown in Figure 1 above.

LEFT OUTER JOIN


EMP_NUM EMP_NAME EMP_AGE EMP_ADDR JOBNUM POSITION SALARY EMP_NUM
11522 Pink Panther 35 16 Panther Crescent 575 Photographer 30000 11522
11533 Tinker Bell 21 5 Sunshine Avenue 501 Editor 35000 11533
11544 Knight Rider 18 10 Disney World 522 Script Writer 25000 11544
11555 Mickey Mouse 30 7 Mouse Drive Null Null Null Null
11566 Tom Cat 22 1 Wall Street 525 Director 85000 11566
11577 Ben Ten 19 101 Dream Street Null Null Null 11577
11588 Silver Star 25 15 Fame Street Null Null Null 11588

You might also like