liveBook · Manning

Entity

As explained in Grokking Relational Database Design

A distinct real-world object or concept that can be described by attributes and represented by data.

An entity is a distinct object or concept that can be described by attributes. In a relational database, a table can represent an entity: each row is one record, and each column is an attribute of that entity. section 1.3 section 1.12

Product as an entity

For an online store, a product is an entity. Its attributes might be name, description, price, and manufacturer. A product table stores those attributes in columns, while each product occupies one row. section 1.3

Entity design starts by turning subjects and characteristics found in requirements into entities and attributes. A subject such as a product, customer, or dealer becomes an entity; its descriptive characteristics become attributes. This work is part of data modeling, whose goal is an entity-relationship diagram. section 4.2 section 4.1

Design an entity by working through these practical decisions:

  • Identify the attributes needed to describe it. section 4.9
  • Choose a primary key that uniquely identifies every row; create a numeric key when no suitable candidate key exists. section 4.9
  • Assign a data type to each attribute by examining sample data and requirements. section 4.9
  • Use a consistent naming convention. Singular names suit primary entities, while plural names can feel natural for table titles. section 4.2

Keep separate entities in separate tables when they describe different things. Combining customer and product information in one table creates redundant data and can cause deletion problems, such as losing a customer record when a product is removed. section 1.3

Entities also provide the endpoints for relationships. After identifying them, define how they relate, determine relationship cardinality, and decide whether any should be represented as weak entities. section 5.0

Extracting entities from requirements

A database for spaceship brands, models, manufactured spaceships, dealers, and customers can identify brand, model, spaceship, dealer, and customer as entities. A prompt can ask ChatGPT to identify entities from stated requirements, with instructions separated from the requirement context. section 8.4 section 8.3

How Grokking Relational Database Design covers it

How deep it goes
Walks through entity identification, attributes, primary keys, data types, naming, and later relationship design.
Examples
Uses online-store products and a spaceship database containing brands, models, spaceships, dealers, and customers.
What it assumes
Teaches entity basics from familiar spreadsheet-like tables while using requirements gathered earlier for design.
What you can do after
Build it from scratch by identifying entities, selecting attributes and keys, and assigning suitable data types.
How it connects
Connects entities to tables, attributes, primary keys, data types, entity-relationship diagrams, cardinality, and weak entities.

Also explained in

Compare how 12 books explain entity →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Relational Database Design. The section links point to the parts of the book it draws on.