The Entity-Relationship Model: Conceptual Data Modeling
The Entity-Relationship Model: Conceptual Data Modeling
Lecture 3
The E-R model is a detailed, logical representation of the data for an organisation or business area It should be understandable to both the user and to the IT technologist The model must be as open as possible and not tied to any technology or to any particular business methodology It must be flexible enough so that it can be used and understood in practically any environment where information is modelled
The ER model
It is expressed in terms of entities in the business environment, the relationships (or associations) among those entities and the attributes (properties) of both the entities and their relationships The E-R model is usually expressed as an E-R diagram
Entity - person, place, object, event, concept Entity Type - is a collection of entities that share common properties or characteristics. Each entity type is given a name, since this name represents a set of items, it is always singular. It is placed inside the box representing the entity type (Fig. 3-1) Entity instance is a single occurrence of an entity type. An entity type is described just once (using metadata) in a database, while many instances of that entity type may be represented by data stored in the database. e.g. there is one EMPLOYEE entity type in most organisations, but there may be hundreds of instances of this entity stored in the database
Is the expense report entity necessary? It is only the result of extracting data from the database. Even though there will be multiple instances of expense reports given to the treasurer over time, data needed to compute the report contents each time are already represented by the ACCOUNT and EXPENSE entity types Gives-to and Receives are business activities, not relationships between entities.
Example of Amity School of inappropriate entities (a) System user (Treasurer) and output (Expense Report) shown as entities
Attributes
An attribute is a property or characteristic of an entity type, for example the entity EMPLOYEE may have attributes Employee_Name and Employee_Address. In ER diagrams place attributes name in an ellipse with a line connecting it to its associated entity Attributes may also be associated with relationships An attribute is associated with exactly one entity or relationship
Some attributes can be broken down into meaningful component parts, such as Address, which can be broken down into Street_Address, City..etc. The component attributes may appear above or below the composite attribute on an ER diagram Provide flexibility to users, as can refer to it as a single unit or to the individual components A simple (atomic) attribute is one that cannot be broken down into smaller components
A composite attribute
It frequently happens that there is an attribute that may have more than one value for a given instance, e.g. EMPLOYEE may have more than one Skill. A multivalued attribute is one that may take on more than one value it is represented by an ellipse with double lines
Entity with a multivalued attribute (Skill) Amity School of Engineering & Technology and derived attribute (Years_Employed)
Some attribute values can be calculated or derived from others e.g., if Years_Employed needs to be calculated for EMPLOYEE, it can be calculated using Date_Employed and Today's_Date A derived attribute is one whose value can be calculated from related attribute values (plus possibly other data not in the database) A derived attribute is signified by an ellipse with a dashed line (see previous Fig.)
Identifier attribute
Identifier attribute or Key is an attribute (or combination of attributes) that uniquely identifies individual instances of an entity type, such as Student_ID To be a candidate identifier, each entity instance must have a single value for the attribute, and the attribute must be associated with each entity The identifier attribute is underlined, such as Student_ID
Composite Identifier
A Composite Identifier is when there is no single (or atomic) that can serve as an identifier Flight_ID is a composite identifier that has component attributes Flight_Number and Date this combination is required to uniquely identify individual occurrences of Flight Flight_ID is underlined, whilst its components are not
Avoid the use of intelligent identifiers whose structure indicates classifications, locations or people that might change. e.g. the first two digits of an identifier may indicate a warehouse location, but such codes are often changed as conditions change, which renders them invalid. Consider substituting new, simple identifiers for long, composite ones, e.g. an attribute called Game_Number could be used for the entity type GAME instead of Home_Team and Away_Team
Amity School of Engineering & Technology (b) Professors and courses (fixed upon constraint)
Overview
The Problem
Programs are complex.
Windows XP: ~45 million lines of code Mathematica: over 1.5 million
Abstraction helps
Many-to-one forget the details Must separate what from how
Information Hiding
By specification
Locality Modifiability
By parameterization
Data Abstraction
What you can do with the data is separated from how it is represented
Specifications What do you want to do? Design How will you do what you want? Implement Code it. Test Check if it works. Maintain School projects dont usually make it this far.
Database Implementation
Database on library web-server stores information on users: userID, name, email, etc. You are responsible for implementing the interface between the web-server and database
What happens when we ask for the email address for a specific user?
Server
Database Client
Client/Server/Database Interaction
Server
Database Client
Help separate what from how Client will use the specifications for interaction with data Client of the web database should not know the guts of the implementation