Thursday, November 6, 2025

Element of a good table (Ref: Database design mere mortals by Michael J. Hernandez)

 Elements of the Ideal Table:

  1. It represents a single subject, which can be an object or event that reduces the risk of potential data integrity problems.

  2. It has a primary key. This is important for two reasons: A primary key uniquely identifies each record within a table, and it plays a key role (no pun intended) in establishing table relationships.

  3. It does not contain multipart or multi-valued fields.

  4. It does not contain calculated fields.

Ex:

Table orders:


id

unit_price

quantity

total_amount

1

10

5

50

2

5

2

10

This is bad table design.

 Problems:

  1. Redundancytotal_amount = unit_price * quantity is stored unnecessarily.

  2. Inconsistency risk → If quantity is updated but total_amount isn’t recalculated, the data becomes wrong.

  3. Extra storage → You’re saving the same information twice (derived + original).

Solution:

id

unit_price

quantity

1

10

5

2

5

2

5. It does not contain unnecessary duplicate fields.

6.It contains only an absolute minimum amount of redundant data.


Javascript module

JavaScript Modules (ES6) let you split code into multiple files and reuse code cleanly. Main keywords: export → make something available...