Class Exercises Relational Algebra - Solution
Class Exercises Relational Algebra - Solution
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.
4.1 Identify the primary keys and foreign keys for the tables in Figure 1.
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.