Let's say I'm building a car rentals application, and at a point I have to show all available cars.
In the DB, I have the following tables:
- Brand
- Model
- Cars
In Model, there is a FK to Brand, let's say Brand_id
So my question is:
Cars table should have Brand and Model columns? Or only a Model column given that I could get the Brand from the Model column?
Basic normal form requires that the car table NOT include a column which is dependent on another (non PK) column in the car table. Since brand is dependent on model, it should not be in the car table.
Put simply, you're storing an awful lot of redundant information if you repeat brand for every car. You can access that info easily by JOINing the model table into a query. And what happens if you have some "car" rows that claim a model belongs to one brand while others claim it belongs to another? That's not only wrong, in the real world it's impossible and therefore it should not be possible in your database.