Several adverts we read asked for database design skills alongside SQL, and an interviewer may ask you to sketch tables for a scenario. Good design is what keeps an app's data trustworthy as it grows. Poor design shows up later as duplicate customers, orders that point to nothing, and totals that never match the mobile money statement.
Start from the real world
List the things (entities) the business cares about and how they relate. For a small shop that sells on WhatsApp, run by Mariama in Bolgatanga:
- A customer places many orders.
- An order contains many order items, each for one product.
- An order can have one or more payments (a first attempt might fail).
Keys
Every table needs a primary key, a column that uniquely identifies each row, usually id. A foreign key is a column that points to a row in another table, such as pointing to . The database can refuse a foreign key that points to nothing, which stops orphan records.