Nepal Oil Corporation2081 BSQuestion 16 of 16
Briefly explain the terms primary key, foreign key and relationships in database management system. Write a query in SQL to display cust_id, cust_name, item_name and item_qty from the tables tbl_customer and tbl_item where item_qty is more than 20; cust_id is a common field in both tables.
10 marks
Question source
- Exam year
- 2081 BS / 2024 AD
- Level
- Level 5
- Paper
- Technical – Subjective
- Section
- Section B: Short & Long Answer Questions (50 Marks)
Model answer
SELECT c.cust_id, c.cust_name, i.item_name, i.item_qty
FROM tbl_customer c
INNER JOIN tbl_item i ON c.cust_id = i.cust_id
WHERE i.item_qty > 20;