Skip to content
SPM Tuition
Computer Science · Data and databases

Distinguishing entities, attributes and relationships

You can list the things in a scenario, but sorting them into the right types goes wrong.

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.

  1. Does it have its own facts that I want to store? If yes, it is an entity.
  2. Is it a fact about something else? If yes, it is an attribute.
  3. 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.

Common questions

What is an entity?

An entity is a thing the database stores data about, such as a student, a book or an appointment. It usually becomes a table. You can normally count entities, and each one has its own properties.

What is an attribute?

An attribute is one property of an entity, such as a student's name or a book's title. It becomes a column in the table. An attribute describes an entity and cannot stand alone as a thing with its own properties.

How do I spot a relationship?

A relationship is the link between two entities, usually a verb phrase such as borrows, teaches or books. In a scenario, look for the verb that connects two nouns. Each relationship later becomes a key link between tables.

If scenario questions leave you unsure what counts as an entity, a one-to-one Computer Science teacher can sort fresh scenarios with you until the test becomes automatic.

  • Online one-to-one lessons for your child with an experienced teacher.
  • Your first class is a one-hour trial, from RM50. The fee is agreed before you book.
  • Happy with the teacher? Continue with lessons of about 1.5 hours. If not, ask for another teacher.