Why is using a common-lookup table to restrict the status of entity wrong?
Posted
by FreshCode
on Stack Overflow
See other posts from Stack Overflow
or by FreshCode
Published on 2010-04-22T14:14:47Z
Indexed on
2010/04/22
14:23 UTC
Read the original article
Hit count: 234
According to Five Simple Database Design Errors You Should Avoid by Anith Sen, using a common-lookup table to store the possible statuses for an entity is a common mistake.
Why is this wrong?
I disagree that it's wrong, citing the example of jobs at a repair service with many possible statuses that generally have a natural flow, eg.:
- Booked In
- Assigned to Technician
- Diagnosing problem
- Waiting for Client Confirmation
- Repaired & Ready for Pickup
- Repaired & Couriered
- Irreparable & Ready for Pickup
- Quote Rejected
Arguably, some of these statuses can be normalised to tables like Couriered Items
, Completed Jobs
and Quotes
(with Pending/Accepted/Rejected statuses), but that feels like unnecessary schema complication.
Another common example would be order statuses that restrict the status of an order, eg:
- Pending
- Completed
- Shipped
- Cancelled
- Refunded
The status titles and descriptions are in one place for editing and are easy to scaffold as a drop-down with a foreign key for dynamic data applications. This has worked well for me in the past. If the business rules dictate the creation of a new order status, I can just add it to OrderStatus
table, without rebuilding my code.
© Stack Overflow or respective owner