You are on page 1of 3

CS403 ASSIGNMENT SOLUTION

BC220419933

COMPANY table:

Comp_ID Comp_Name Comp_City Comp_Ph#

C001 Toyota Islamabad 051-321002

C002 Honda Lahore 042-321002

C003 Suzuki Peshawar 091-321002

C004 MITSUBISHI Quetta 081-321002

C005 Nissan Gilgit 092-321002

ITEM table:

Item_ID Item_Name Item_Unit Item_Quantit CID


y

1 Lights PCs 50 C001


2 Bumper PCs 20 C002
3 Seats Set 10 C003
4 Tires Set 60
5 Engine PCs 5
6 Breaks Set 14 C005

i) Theta join on Company and Item Tables having a condition Item_Unit = PCs

(σ Item Unit = ‘PCs’ (ITEM) ) X COMPANY


Item_ID Item_Name Item_Unit Item_Quantity CID Comp_ID Comp_Nam

1 Lights PCs 50 C001 C001 Toyota

1 Lights PCs 50 C001 C002 Honda

1 Lights PCs 50 C001 C003 Suzuki

1 Lights PCs 50 C001 C004 MITSUBIS

1 Lights PCs 50 C001 C005 Nissan

2 Bumper PCs 20 C002 C001 Toyota

2 Bumper PCs 20 C002 C002 Honda


2 Bumper PCs 20 C002 C003 Suzuki

2 Bumper PCs 20 C002 C004 MITSUBIS

2 Bumper PCs 20 C002 C005 Nissan

5 Engine PCs 5 C001 Nissan

5 Engine PCs 5 C002 Toyota

5 Engine PCs 5 C003 Honda

5 Engine PCs 5 C004 Suzuki

5 Engine PCs 5 C005 MITSUBIS

ii. EQUI join on Company and Item tables

σ COMPANY.comp ID = ITEM.CID (COMPANY X ITEM)

Comp_ID Comp_Name Comp_City Comp_Ph# Item_ID Item_Name Item_Unit Item_

C001 Toyota Islamabad 051-321002 1 Lights PCs 50

C002 Honda Lahore 042-321002 2 Bumper PCs 20

C003 Suzuki Peshawar 091-321002 3 Seats Set 10

C005 Nissan Gilgit 092-321002 6 Breaks Set 14

iii. Natural join on Company and Item tables.

COMPANY X ITEM
Comp_ID Comp_Name Comp_City Comp_Ph# Item_ID Item_Name Item_Unit

C001 Toyota Islamabad 051-321002 1 Lights PCs

C002 Honda Lahore 042-321002 2 Bumper PCs

C003 Suzuki Peshawar 091-321002 3 Seats Set

C005 Nissan Gilgit 092-321002 6 Breaks Set

iv. Semi join on Company and Item tables.

π COMPANY (COMPANY X ITEM)

Comp_ID Comp_Name Comp_City Comp_Ph#

C001 Toyota Islamabad 051-321002

C002 Honda Lahore 042-321002

C003 Suzuki Peshawar 091-321002

C005 Nissan Gilgit 092-321002

You might also like