160 likes | 295 Views
Microsoft Access. CS 110 Fall 2005. Entity Relationship Model. Entities Principal data object about which information is to be collected employees, projects, invoices, etc. Relationships An association between two or more entities employees are assigned to projects. Entities.
E N D
Microsoft Access CS 110 Fall 2005
Entity Relationship Model • Entities • Principal data object about which information is to be collected • employees, projects, invoices, etc. • Relationships • An association between two or more entities • employees are assigned to projects
Entities • Entities have attributes • name, ID, key • May be a way to uniquely identify an instance of an entity • May be a non-unique characteristic of an entity instance
Relationships • Relationships have connectivity and cardinality • One-to-one – at most one instance of entity A is associated with one instance of entity B • One-to-many – one instance of entity A is associated with zero, one, or many instances of entity B • Many-to-many – one instance of entity A is associated with zero, one, or many instances of B (and vice versa)
Building a data model • Identify entities and relationships • What are the entity attributes • Confirm the desired query results can be generated
What makes an object an entity or an attribute? • “Employees work on projects” Are employees an entity or an attribute of projects? • Analyze narratives from users, meeting notes, policy and procedure documents, … • Consider database properties
Normalization • Put data into table form by removing repeated groups and duplicated data • A theoretical definition based on logic exists
Example • A company obtains parts from multiple suppliers • Each supplier is in a city • A city can have more than one supplier • Each city has a status code • Each supplier may provide many parts
Example • s#: supplier ID • status: city status • city: name • p#: part ID • qty: quantity
Redundant data • City and status repeated for each part
Update anomalies • Problems that occur when information is inserted, deleted, or updated • Caused by redundant data
Insert anomalies • Cannot addnew supplierw/o addingpart supplied
Delete anomalies • Deleting a row loses information about quantity/part AND supplier
Update anomalies • If supplier s1 moves from NY to London, six rows must be updated
Refinement • Following rigor of normalization, tables are split/merged to reduce anomalies
Primary, secondary, and foreign keys • Primary key: attribute that uniquely identifies all other attributes in a row • Secondary key: attribute that identifies a set of records • Foreign key: attribute in one table that matches the primary key of another