Database Design
ER Diagram Symbols
Master the visual language of ER diagrams by learning every symbol, notation, and drawing convention that database designers use to communicate complex data structures.
ER diagrams use a specific visual language. Think of it like reading a blueprint - architects have standard symbols for doors, windows, and electrical outlets. Database designers have standard symbols for entities, attributes, and relationships.
Every symbol means something precise. A rectangle isn't just a shape - it represents an entity. A diamond isn't decoration - it shows a relationship. Understanding these symbols lets you read any ER diagram and communicate your database designs clearly.
Entity Symbols
Entities represent the "things" in your database. They get drawn as rectangles with the entity name inside. Simple, but there are important variations.
Single border
Independent existence
Double border
Depends on parent
Strong entities exist independently. A Customer can exist whether they've placed orders or not. Weak entities need a parent to exist. An OrderItem only makes sense if an Order exists first.
BookVault has both types. Books, Authors, and Customers are strong entities - they exist on their own. OrderItems are weak entities - they can't exist without an Order.
Attribute Symbols
Attributes describe entity properties. They get drawn as ovals connected to entities. But different attribute types use different symbols.
Simple Attributes
Regular oval shape. Contains a single atomic value like first_name or price.
Key Attributes
Oval with underlined text. Uniquely identifies each entity instance like customer_id.
Composite Attributes
Oval connected to smaller ovals. Like full_name breaking into first_name and last_name.
Derived Attributes
Dashed oval border. Calculated from other attributes like age derived from birth_date.
Why does this matter? Different attribute types become different database columns. A composite attribute like "address" might become multiple columns: street, city, state, zip_code.
Real Example
In BookVault, a Customer entity might have email as a key attribute, name as composite (first_name + last_name), and account_age as derived from created_at date.
Relationship Symbols
Relationships connect entities. They get drawn as diamonds with the relationship name inside. The connecting lines show how many instances participate.
The diamond contains the relationship verb - "places", "contains", "writes". The lines show cardinality - how many of each entity can participate.
Cardinality Notation
Different notation styles exist for showing cardinality. Chen notation uses 1, M, N labels. Crow's foot notation uses symbols that look like bird feet.
Chen Notation
M — many (multiple)
N — many (alternative)
0..1 — zero or one
1..* — one or more
Crow's Foot
|< — one or more
>< — zero or more
|o — zero or one
Popular in tools like ERwin
BookVault uses Chen notation because it's clearer for learning. A Customer places many Orders (1:M). An Order contains many Books, and a Book appears in many Orders (M:N).
Advanced Symbols
Real databases need more sophisticated symbols for complex scenarios. These handle inheritance, participation constraints, and multi-valued attributes.
Participation Constraints
Does every entity instance have to participate in a relationship? Total participation means yes - drawn with double lines. Partial participation means optional - drawn with single lines.
Common Mistake
Drawing every relationship line the same thickness. Use double lines when an entity MUST participate. In BookVault, every OrderItem must belong to an Order (total participation), but not every Customer must have Orders (partial participation).
Multi-valued Attributes
Some attributes can have multiple values. A Book might have multiple genres. These get drawn as double ovals - an oval inside another oval.
Multi-valued attributes create implementation challenges. You can't store multiple genres in a single database column easily. Usually, you create a separate table instead.
ISA Relationships (Inheritance)
Sometimes entities share common attributes but have specialized properties. Think "User" as a parent, with "Customer" and "Admin" as children. This uses ISA triangles.
Data Insight
Amazon uses inheritance extensively. They have a base "Product" entity with specialized entities for "Book", "Electronics", and "Clothing" - each with unique attributes while sharing common properties like price and description.
Symbol Combinations in Practice
Real ER diagrams combine all these symbols. Here's how BookVault's Order and OrderItem relationship looks with proper notation:
customer_id
order_date
total_amount
FK book_id
quantity
unit_price
Double border = weak entity (OrderItems can't exist without Orders)
Notice the symbols working together. The OrderItem entity has a double border (weak entity). The relationship line has double thickness (total participation). The order_id attribute shows as FK (foreign key).
From Symbols to SQL
These symbols translate directly to SQL table structure. Here's how the above diagram becomes actual database tables:
-- Strong entity becomes independent table
-- Primary key from key attribute (underlined in ER diagram)
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT NOT NULL,
order_date DATE NOT NULL,
total_amount DECIMAL(10,2)
);
-- Weak entity becomes dependent table
-- Foreign key relationship enforces total participation
CREATE TABLE order_items (
order_item_id INT PRIMARY KEY,
order_id INT NOT NULL, -- FK from parent entity
book_id INT NOT NULL,
quantity INT NOT NULL,
unit_price DECIMAL(10,2),
FOREIGN KEY (order_id) REFERENCES orders(order_id)
ON DELETE CASCADE -- Weak entity dies with parent
);
Table 'orders' created successfully. Table 'order_items' created successfully. Foreign key constraint 'order_items_ibfk_1' applied: - order_items.order_id → orders.order_id - CASCADE DELETE enabled (weak entity behavior)
What just happened?
The ER symbols became SQL constraints. The double border (weak entity) became CASCADE DELETE. The double line (total participation) became NOT NULL foreign key. Try this: create a simple ER diagram for a Library system with Books and Authors, then write the corresponding SQL.
Reading vs Drawing ER Diagrams
You'll read ER diagrams more often than draw them. But understanding symbols helps both activities. When you see a diagram, ask these questions:
Reading Checklist
- Which entities are weak? (double borders)
- What are the key attributes? (underlined)
- Which relationships are mandatory? (double lines)
- What's the cardinality? (1, M, N labels)
Drawing Tips
- Start with entities (rectangles) first
- Add key attributes (underlined ovals)
- Connect relationships (diamonds)
- Mark cardinality and participation last
Professional tip: most database design tools handle symbol drawing for you. Focus on understanding what each symbol means rather than perfect drawing technique.
Companies like Netflix have ER diagrams with hundreds of entities. The symbols stay the same whether you have 3 tables or 300. Master the basics and you can understand any system's design.
Quiz
1. In BookVault's ER diagram, how should you draw the Orders and OrderItems entities to show that OrderItems cannot exist without an Order?
2. A Book in BookVault can belong to multiple genres (Fiction, Mystery, Romance). Which ER diagram symbol correctly represents the "genres" attribute?
3. In BookVault, every OrderItem must belong to exactly one Order, but Orders can exist without OrderItems. How should you draw the relationship line from OrderItems to the "belongs_to" relationship?
Up Next
One-to-One Relationships
Now that you know the symbols, we'll explore the simplest relationship type and learn when to use one-to-one connections in database design.