Q.The school canteen wants to maintain records of items available in the school canteen and generate bills when students purchase any item from the canteen. The school wants to create a canteen database to keep track of items in the canteen and the items purchased by students. Design a database by answering the following questions:
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →This is a database design problem. The solution uses two relations: Item (item details stored once) and Bill (purchase records linked via foreign key). Calories belong in the Item relation.
This question tests your understanding of database normalization — the idea that you should store each fact in exactly one place to avoid redundancy and update anomalies. The canteen scenario is a classic one-to-many relationship: one item can appear in many bills, but each bill line refers to exactly one item.
Let's break it down part by part.
(a) To store each item name along with its price, you need a relation that captures the item master data. Since each item and its price should be stored only once, this is a single table with a unique identifier for each item.
Relation name: Item
Attributes and data types:
item_id—INT(orINTEGER), primary key. This uniquely identifies each item.item_name—VARCHAR(100)(orTEXT). Stores the name of the item.price—DECIMAL(10,2)(orFLOAT/NUMERIC). Stores the price in rupees with two decimal places.
Restriction: The primary key constraint on item_id ensures each item is stored only once. Additionally, you could add a UNIQUE constraint on item_name if item names are also unique, but the question only requires that each item and its price be stored once — the primary key achieves that.
Do not store price in a separate table without linking it to the item — that would break the "stored only once" rule and create redundancy.
(b) The quantity of an item purchased is transactional data — it changes with every purchase. This should not be in the Item relation because that would force you to update the item's row every time someone buys it, which is messy and loses history. Instead, create a new relation for the bill/purchase details.
Relation name: Bill
Attributes and data types:
bill_no—INT, primary key. Uniquely identifies each bill.item_id—INT, foreign key referencingItem(item_id). Links the purchase to a specific item.quantity—INT(orSMALLINT). Stores how many units of that item were purchased.purchase_date—DATE(optional but practical). Not required by the question, but good practice.
Primary key: bill_no — this satisfies restriction (i): the same bill number cannot appear twice, so different orders get different bill numbers.
Foreign key: item_id references Item(item_id) — this satisfies restriction (ii): a bill can only be generated for an item that exists in the Item table. The database will reject any attempt to insert a bill with an item_id that is not present in Item. …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.