r/SQL • • 23h ago

Discussion Does this table meet the normalization requirements (1NF, 2NF, and 3NF)?

Post image

I’m working on a database project for a metro system, and I’m not sure if my Train table satisfies 3NF.
I think Capacity depends on TrainModel rather than TrainID. If I enter different capacity values for trains of the same model, would that solve the problem, or would it still violate 3NF?
Should I remove Capacity from the table?

0 Upvotes

6 comments sorted by

13

u/blueberrywalrus 23h ago

If capacity depends on train model and not Train ID then it needs to be split into a different table for 3NF.

Right now, it looks like capacity is specific to each Train ID which would make this table 3NF.

However, encoding train model into the serial number could be seen by some as a dependency.

8

u/DailyDrillsApp 23h ago

3NF is about the real-world rule, not the values you happen to type in. If every train of the same model always has the same capacity, then TrainID → TrainModel → Capacity is a transitive dependency, and entering different numbers doesn't fix that. It just lets your data contradict the rule. Move it out: TrainModel(TrainModel PK, Capacity) and keep TrainModel as a FK in Train, then JOIN when you need the capacity. If capacity really can differ per individual train (refits, extra cars, etc.), it's a fact about that train and can stay where it is.

1

u/hrtprobablysoon 21h ago

Nope as they are shown unique values

1

u/rohan_sqldev 19h ago

Assuming each individual train can have its own seating layout, yeah, this already meets 3NF.

There are no repeating groups and TrainID uniquely identifies each row (with SerialNumber as a candidate key), so 1NF is good. Since TrainID is a single-column primary key, you don't have to worry about partial dependencies for 2NF either.

The only potential 3NF issue here would be if Capacity was fixed per TrainModel, since that would create a transitive dependency. Looking at your sample rows though, Metropolis26 shows up with 120, 150, 180, etc., so capacity clearly belongs to the specific train unit rather than the model. In a real production DB you could still pull TrainModel and Status out into small lookup tables just to keep things clean, but strictly speaking it's already normalized.

1

u/sumwise_victor 7h ago

Normalization depends on the real-world rule, not the sample rows you type in.

If every train of a given model always has the same capacity (TrainID -> TrainModel -> Capacity), that is a transitive dependency and violates 3NF. Manually typing different numbers for two trains of the same model doesn't fix it.

Clean 3NF fix: move Capacity into a separate TrainModels(TrainModel PK, Capacity) table and keep TrainModel as a foreign key on Trains. The only case where Capacity stays in Trains is if individual trains of the same model can legitimately be retrofitted to have different seating capacities.