Draw an ER diagram for a small retail shop and explain its components.
How to lay out the answer. Follow the frame, then write it in your own words.
1 · Open in two lines. An entity relationship (ER) model is a diagram used to plan a database. It shows entities, attributes and the relationships between them.
2 · Identify the entities. Customer, Order, Product and Supplier, each drawn as a rectangle.
3 · Attributes and keys. Customer (CustomerID, Name, City), Order (OrderID, Date), Product (ProductCode, Name, Price), Supplier (SupplierID, Name). Underline each key.
4 · Relationships and cardinality.
Customer places Order: one-to-many.
Order contains Product: many-to-many.
Supplier supplies Product: one-to-many.
5 · Draw the diagram. [Diagram: rectangles for the four entities, diamonds for places, contains and supplies, ovals for attributes, lines marked 1, M and N]
6 · Resolve M:N and convert to tables. Add an Order_Line table (OrderID, ProductCode, Quantity); put CustomerID into Order and SupplierID into Product as foreign keys.
7 · Sri Lankan business example. A bus company models Route, Trip and Bus the same way before building its online seat booking.
8 · Close in one line. A clear ER model prevents design mistakes before any table is built.
Scoring tip: Draw the diagram large and neat with the 1, M and N marks; it carries most of the marks.