Data structure considerations
When first designing our database, we decide how the data will be stored—which data resides in which tables, the data types of all the columns, and how the tables are related. At this stage, we will define the primary keys (PK) for all our tables, and then foreign keys (FK) can be added to define the relationships between the tables.
Generally, the primary key of a table is evident based on the data that is contained in the table, but if there's no natural key in the data itself, we may have to create a surrogate key by using some sort of unique value generated by the database. When we create a primary key on a table in SQL Server, a clustered index will be generated by default to support the key. As we discussed ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access