Database Design Project · Lesson 109 of 112

Database Project Requirements and Entities

What you will learn

  • How to turn a business description into requirements
  • How to list the questions the database must answer
  • How to pick entities and attributes
  • How to decide what is not needed yet

1. The project

In the next three lessons you will design and build a small database from nothing. The customer is a made-up tailor shop. The owner says:

"Customers bring cloth or ask me to sew a shirt, trousers or a panjabi. I write the order in a notebook with the date and when it is due. An order can have several garments. I need to know which orders are not finished, what a customer owes in total, and which garment sells most. Two customers can have the same name, but not the same phone number. Prices change over time, and I must not change old orders when they do."

The shop, the owner and the numbers are all invented for this lesson.

2. Requirements

Read the description slowly and write each fact as a short, testable requirement:

# Requirement
R1 Keep customers with a name and a phone number; phone numbers are unique
R2 Keep a list of garments the shop makes, each with a current price
R3 Keep orders: which customer, date ordered, date due, and a status (new, sewing, ready, collected)
R4 An order has one or more garments, each with a quantity
R5 An order must remember the price at the time of ordering, even if the garment's price changes later
R6 A due date cannot be earlier than the order date

The last two come from the owner's last sentence. Spotting hidden requirements like R5 is the real skill: the notebook never said "store the price twice", but the business needs it.

3. Questions

List what the database must answer. These later become queries (lesson 15.3):

# Question
Q1 Which orders are not collected yet, soonest due first?
Q2 What is the total of each order?
Q3 What has each customer ordered in total? (including customers with no orders)
Q4 Which garment is ordered most?
Q5 Which customers have never ordered?

4. Entities and attributes

Look for the nouns with their own facts (lesson 3.6):

Entity Attributes
Customer name, phone
Garment name, price
Order date ordered, date due, status, the customer
Order item the order, the garment, quantity, price at the time

Order item appears because of R4: an order has many garments and a garment appears in many orders, a many-to-many relationship (lesson 3.4), so it needs a junction table.

5. What we leave out

Good design also decides what to skip for now. The shop did not ask for measurements, payments or staff, so we do not model them. They can be added later as new tables without breaking these ones. Keeping the first version small makes it finished.

Worked example: check the entities against the questions

Question Which tables answer it?
Q1 orders (status, due date), customers (name)
Q2 orders, order items (quantity, price)
Q3 customers, orders, order items
Q4 garments, order items
Q5 customers, orders

Every question can be answered from the four planned tables, so the entity list is complete for this version.

Common mistakes

  • Starting with tables before requirements. You will build the wrong thing quickly.
  • Missing hidden requirements, such as keeping the price at the time of ordering.
  • Modelling everything the shop might ever do. Start with what it asked for.
  • Not listing the questions. They are the test of the design.

Key takeaways

  • Turn the description into short, testable requirements, including hidden ones.
  • List the questions the database must answer.
  • Entities are the nouns with their own facts; many-to-many relationships need a junction table.
  • Leave out what was not asked, and check each question against the planned tables.

Practice

1. What hidden requirement did the owner's last sentence contain?

Show answer

Each order item must store the price at the time of ordering, so later price changes do not alter old orders.

2. Why is "order item" a separate entity?

Show answer

Orders and garments are many-to-many, so a junction table is needed; it also holds quantity and the price at the time.

3. The owner adds: "I want to know who collected each order, and when." Write the new requirement, say which table it changes, and say whether any existing requirement breaks.

Show answer

For example "R7: keep who collected an order and when". It adds columns (collected by, collected on) to orders, or a small new table if several people can collect. No existing requirement breaks, because it only adds facts; this is why the first version can stay small.

4. Which table answers Q5 together with customers?

Show answer

Orders: a customer with no rows in orders has never ordered.

5. Why leave measurements out of the first version?

Show answer

They were not asked for; a small first version gets finished, and a table can be added later without breaking the others.

6. Write one more question the owner might ask.

Show answer

For example: "Which orders are due in the next three days?"