You are on page 1of 2

PUNJAB UNIVERSITY COLLEGE OF

INFORMATION TECHNOLOGY (PUCIT)


Database Lab 02

CS Morning F-19 (New Campus)


Date: 11-03-2021
Instructions:

• You’re not allowed to consult your classmates during lab work. (As of course
it won’t go in your benefit)
• To seek any help, consult with the TAs.
• Solve the lab on blank paper and don’t forget to write your roll number
and name.
1. Define Union and Intersection:
a) Return a relation consisting of all the tuples appearing in either or all the relations.
b) Return a relation representing the intersection of the tables below.

ID Name Age Department NIC


J1 Ahmad 23 Sales 245-77-245367
J2 Salman 34 Marketing 234-66-245368
J5 Tariq 29 Admin 245-71-325370

ID Name Age Department NIC


J1 Ahmad 23 Sales 245-77-245367
J2 Salman 34 Marketing 234-66-245368
J4 Tariq 29 Admin 245-71-325370

ID Name Age Department NIC


J1 Ahmad 23 Sales 245-77-245367
J2 Salman 34 Marketing 234-66-245368
J5 Tariq 29 Admin 245-71-325370

Teaching Assistants: Instructor:


Fatima Tuz Zahra – BCSF17M540 Farhan Ahmad Ch.
Areej Ehsan – BCSF17M512
2. What is Cardinality? Write down the cardinality of all tables of Question 1.

3. What is Degree? Write down the degree of the table below:

ID First Name Last Name Age Country


1 Alfreds Anders 12 Berlin
2 Ana Trujillo 19 México D.F.
3 Antonio Moreno 21 México D.F.
4 James Hardy 23. London
5 John Berglund 34 Luleå

4. Find:
Relation A
ID FirstName Last Name Hire Year
S1 Betsy Adams 2008
S2 Ryan Potter 2010
S3 Arnold Elfis 2008
S4 Ryan Potter 2013

Relation B
ID FirstName Last Name Hire Year
S1 Betsy Adams 2008
S2 Ryan Potter 2010
S3 Arnold Elfis 2008
S4 Ryan Potter 2013
S6 Susan Reyna 2009

i) Find A Times B
ii) Find (A TIMES B) where IDA > IDB
iii) Find (A TIMES B) where IDA = IDB
iv) Find (A TIMES B) where IDA < IDB
v) Find A-B
vi) Find B-A

You might also like