An entity is a thing you store data about. An attribute is one fact about that thing, and a relationship is the link between two entities.
This lesson opens data and databases. Next you can learn to choose primary and foreign keys.
What are the three sorting questions?
Ask these about each word in a scenario.
- Does it have its own facts that I want to store? If yes, it is an entity.
- Is it a fact about something else? If yes, it is an attribute.
- Is it an action that joins two entities? If yes, it is a relationship.
Worked example: a small clinic
Scenario: a clinic records each patient’s name and phone number. A patient books an appointment with a doctor, and each doctor has a room number.
| Word | Question answered | Type |
|---|---|---|
| Patient | has its own facts (name, phone) | entity |
| Doctor | has its own facts (room number) | entity |
| name, phone number | facts about a patient | attributes of Patient |
| room number | fact about a doctor | attribute of Doctor |
| books an appointment with | joins Patient and Doctor | relationship |
The appointment could also be an entity if you want to store its date and time. The scenario decides, because a thing with its own facts is an entity.
The mistake that costs marks
Students often label a value or a fact as an entity. They write “phone number” as an entity because it is a noun.
| Word | Wrong type | Right type | Why |
|---|---|---|---|
| phone number | entity | attribute | it describes a patient |
| Patient | attribute | entity | it has its own facts |
The fix is question 2: does this word describe something else? If it does, it is an attribute.
Check yourself
A school library stores each book’s title and ISBN. A member borrows a book, and a member has a name and a class. Sort each item: Book, title, Member, borrows, class.
Answer
Entities: Book and Member, because each has its own facts.
Attributes: title (of Book) and class (of Member).
Relationship: borrows, which joins Member and Book.
What to study next
Once you can sort the parts, link them with keys. Continue with choosing primary and foreign keys, then read how to read an entity relationship diagram.
If you want a teacher to sort scenarios with you, see online one-to-one Computer Science tuition.