20 min read
Entities
An entity is what a table is about — members, books, or courses. Name it before you build the table.
Before you build a table, decide what it is about. That subject has a name in database design: an entity.
An entity is a major thing you store data about. Each entity becomes its own table.
How to spot an entity
Ask three questions.
Is it one kind of thing? Members are people who joined. Books are titles. Those are entities. The library building is not one entity — it is the place that holds several entities.
Would one row stand for one of them? One row = one member. One row = one book. If a row would mix a person and a title, you have two entities in one list.
Does it have its own facts? A member has a phone. A book has an author. A loan has a date. Each entity has attributes — facts that belong to it.
| Entities at the library | ||
|---|---|---|
Do not name a table "Library" or "Data". Those words describe the whole project, not one kind of thing. Inside the library you will find several entities.
Another setting
A nearby school keeps students and courses as separate entities. Sophie Walsh can be a student. Database Fundamentals can be a course. Those are two entities — two tables.
| Students | |
|---|---|
| Courses | |
|---|---|
If the school put every course title on Sophie's student row, the row would break the first time she enrolled in a second course. Students in Students. Courses in Courses. Enrolments — who takes what — get their own table later, just as loans do at the library.
From entity to table
Practice
Swipe or use the arrows to move between questions.
1 / 3
More lessons in Database Fundamentals · Next: Fields and Records · Previous: What is a Table?
