CSE Roadmap

Core tier · about 3 hours · 5 parts

Part 2 of 5 · 1 min read

Entities, attributes and relationships

The three basic building blocks of an entity-relationship diagram.

Think of planning a school's records before building any database at all. Students exist, teachers exist, and a relationship connects certain students to certain teachers, such as "is taught by."

In plain words: an entity is a real-world thing worth tracking on its own, such as a customer or a book. An attribute is a property of an entity, such as a customer's name. A relationship connects two or more entities, such as a customer placing an order.

A worked example. In the bookstore, Customer and Book are entities. name and address are attributes of Customer. "places" is the relationship connecting a Customer to an Order.

The key lines. No SQL yet; an ER diagram is drawn before any table exists.

Customer --- places ---> Order

Entity, attribute, relationship

An entity is a distinct real-world thing worth tracking. An attribute is a property of an entity. A relationship connects two or more entities.

Example: Customer is an entity, address is one of its attributes, and "places" is the relationship connecting Customer to Order.