This post will examine how to map a data model to a database.
For a basic data model, decisions are made on whether to classify objects as “things” or “attributes“. Consider an application built for managing audio tracks.
To map the data model from a logic model to a physical model, a database, you have to augment your table. Foreign keys are used to augment a table. Each foreign key points to a primary key of another table.
Primary Keys, Foreign Keys, Logical Keys
For an application that manages audio tracks, the albums should be numbered. These numbers would be called the primary keys or the “id“. For an album numbered 4, then that primary key “id” would be listed as the foreign key “album_id” for a track that is on that album.
Primary keys become end points that a foreign key would point to. The logical key is something you might use in an SQL WHERE clause.
It is important to have a naming convention for any data model. It makes drawing out the data model much easier.