Docsity

Cartesian Product-Database Management System-Assignment Solution, Exercises of Database Management Systems (DBMS)

Toggle sidebar
bg1
CS403: Database Management Systems Spring 2012 Assignment No. 2 Solution File
- 1 โ€“
Virtual University Of Pakistan
Assignment No. 02
Total Marks: 10
Assignment:
(a). Find out the Cartesian product (D1 ร— D2 ร— D3) of the given pair of sets. Marks: 5
D1 => Set of first two Vowels = D1 = {A, E}
D2 => Set of three country codes = D2 = {213,54, 994}
D3 => Set of first three odd numbers = D3 = {1, 3, 5}
Solution: D1 ร— D2 ร— D3 = 2 ร— 3 ร— 3 = 18 Subsets
Where 2 represent the number of elements in set D1, 3 for D2 and again 3 for D3.
D1 ร— D2 ร— D3 = (A,213,1),(A,213,3),(A,213,5)(A,54,1), (A,54,3),( A,54,5),(A,994,1),(A,994,3),( A,994,5),
(E,213,1),(E,213,3), (E,213,5),(E,54,1),(E,54,3),(E,54,5),(E,994,1),( E,994,3),(E,994,5)
(b). Keeping in view the previous assignment scenario lets suppose there is a simple database for some
entities in LMS might contain relations for Student, Class, Faculty and Enrollment. The relation schema
would be written as:
Student (Stu_Id, LastName, FirstName, Major, Credits)
Faculty (Fac_Id, department, rank, name)
Class (Class_No, Fac_Id, Schedule, room)
Enrollment (Stu_Id, Class_No, Grade)
Using this sample relational schema, identify foreign key in Class relation and Composite primary key in
Enrollment relation. Marks: 5
docsity.com
pf2

Partial preview of the text

Download Cartesian Product-Database Management System-Assignment Solution and more Exercises Database Management Systems (DBMS) in PDF only on Docsity!

CS403: Database Management Systems Spring 2012 Assignment No. 2 Solution File

Virtual University Of Pakistan

Assignment No. 02 Total Marks: 10

Assignment:

(a). Find out the Cartesian product (D 1 ร— D 2 ร— D 3 ) of the given pair of sets. Marks: 5

D 1 => Set of first two Vowels = D 1 = {A, E} D 2 => Set of three country codes = D 2 = {213,54, 994} D 3 => Set of first three odd numbers = D 3 = {1, 3, 5}

Solution: D 1 ร— D 2 ร— D 3 = 2 ร— 3 ร— 3 = 18 Subsets

Where 2 represent the number of elements in set D1, 3 for D 2 and again 3 for D 3.

D 1 ร— D 2 ร— D 3 = (A,213,1),(A,213,3),(A,213,5)(A,54,1), (A,54,3),( A,54,5),(A,994,1),(A,994,3),( A,994,5),

(E,213,1),(E,213,3), (E,213,5),(E,54,1),(E,54,3),(E,54,5),(E,994,1),( E,994,3),(E,994,5)

(b). Keeping in view the previous assignment scenario lets suppose there is a simple database for some entities in LMS might contain relations for Student, Class, Faculty and Enrollment. The relation schema would be written as:

Student (Stu_Id, LastName, FirstName, Major, Credits) Faculty (Fac_Id, department, rank, name) Class (Class_No, Fac_Id, Schedule, room) Enrollment (Stu_Id, Class_No, Grade)

Using this sample relational schema, identify foreign key in Class relation and Composite primary key in

Enrollment relation. Marks: 5

docsity.com

CS403: Database Management Systems Spring 2012 Assignment No. 2 Solution File

Virtual University Of Pakistan

Solution: 1. Keeping in mind the definition of foreign key, here Fac_Id would behave as a

foreign key in Class relation as it is used as primary key in the Faculty relation. This

attribute will also be used to join these two relations (Faculty and Class).

2. Stu_Id and Class_No will jointly behave as composite primary key in

Enrollment relation.

docsity.com