liveBook · Manning

Primary key

As explained in Building Web APIs with ASP.NET Core

A primary key is a property or column whose value uniquely identifies a record in an entity or table.

A primary key is a property or column whose value uniquely identifies each record of a given type. In SQL, it provides the stable identity needed to connect related table records. section 4.1.1

Use primary keys to structure relationships in a table-oriented database:

  • Give each record in tables such as Users, Roles, BoardGames, and Comments a unique identity. section 4.1.1
  • Add a referencing column where another table needs to point to a record; Comments can use BoardGameID to associate each comment with one board game. section 4.1.1
  • Contrast this design with NoSQL, where related information is often embedded in parent documents and key-based relationships are used selectively. section 4.1.1
Figure 4.1 MyBGList database schema diagram for a table-oriented SQL database
04-01

Use the SQL schema diagram to trace primary-key identities and the columns that reference related records across tables. section 4.1.1

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines uniqueness and demonstrates cross-table references, but stops short of explaining key-generation or constraint implementation.
Examples
Uses Users, Roles, BoardGames, Comments, and the Comments.BoardGameID reference as concrete schema examples.
What you can do after
Evaluate how a relational schema identifies records and represents relationships between tables.
How it connects
Connects primary keys with SQL databases, table relationships, database schemas, NoSQL databases, and document embedding.

Also explained in

Compare how 21 books explain primary key →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.