E/R → Entity-Relationship Model
Q: How should we design tables in our database?
- Tables are not "given"
- "Good" tables may not be easy to come up with
E/R Model: graphical, intuitive and "informal" representation of information on database
- Used to capture what we learn from domain experts/database users
- Not directly implemented by DBMS
- Tools exist to automatically convert E/R model into tables
2 Important topic: Entity sets and relationship sets
Entity Set
- Entity: "thing" or "object" in real world
- Entity set: a set of entities(objects). Like a class in OOP
- Rectangle in ER
- Consists of "name" and "attributes"
- Entities with attributes can be thought as "tuples" or records
- Key: A set of attributes that uniquely identifiers an entity in an entity set
- Underline in E/R
- All entity sets in E/R need a key
Relationship Set
- Relationship: "Connection" between entites
- Relationship set: a set of relations of the same kind
- Diamond in ER
- Relationships can be thought as "edges" between entities
- Relationships can have attributes
- Not all entities have to participate in a relationship
Cardinality of Relationships