Database Design Principles – Lecture 3 Conceptual Database Design – identifying entities
Lecture Objectives Discovering Entities
Discovering Entities Using a top down approach, identify the major ‘things’ a business needs to store information about == entities Document these in a conceptual model Model will show the following: Entity – something about which someone wants to store data; typically a person, a place, a thing, a concept, or an event
Discovering Entities Requirements gathering – focusing on data: Interview end users Review existing documentation (forms, reports) Brainstorming Overview of the business Questionnaires Review system documentation Functional/non-functional requirements Work flow diagrams Data flow diagrams Use case descriptions
Discovering Entities Use a technique like ‘noun filtering’ Look for nouns that describe data Similar nouns can be grouped into an entity Some nouns will become attributes
Discovering Entities Generally, nouns translate into entities
Sample Conceptual Model - ERD This is a preliminary conceptual model. Model shows entities without attributes or relationships.
Entity Corresponds to a table and not to a row in the relational environment Can be strong or weak Entity name is a noun
Entity Entity can be strong or weak Strong Entity (existence independent) Does not depend on the existence of some other entity to exist Each entity occurrence of a strong entity is uniquely identifiable using the primary key attributes of that entity type Weak relationship (non-identifying) Can identify each Plan based on a plan code and can identify each Client by a client code. Therefore, both are strong entities.
Entity Entity can be strong or weak Weak Entity (existence dependent) Does depend on the existence of some other entity in order to exist Cannot identify each occurrence of the Dependent. We can only Identify the Dependent by Knowing the Parent, through the primary key of the Parent. Can identify each parent based on a primary key (therefore it is a strong entity type) and can only identify each dependent only by knowing the Parent. Therefore dependent is a weak entity.
Discovering Relationships Verbs translate into relationships among entities Relationships are bi-directional Need to know the following: Optionality Cardinality
Relationship Participation Optional participation One entity occurrence does not require corresponding entity occurrence in particular relationship Mandatory participation One entity occurrence requires corresponding entity occurrence in particular relationship
Relationship Participation
Relationship Participation
The Entity Relationship Model Widely accepted and adapted graphical tool for data modeling Introduced by Chen in 1976 Graphical representation of entities and their relationships in a database structure
The Entity Relationship Model
The Entity Relationship Model
In Summary Steps to create a conceptual model Identify entities Identify relationships between entities taking into consideration the business rules
Discovering Business Rules Constrain some part of the business For example: An employee can only choose one benefit plan An employee may or may not have dependents An employee may opt out of a benefit
Discovering Business Rules Sources of Business Rules: Company managers Policy makers Department managers Written documentation Procedures Standards Operations manuals Direct interviews with end users
Summary Entity relationship (ER) model Uses ERD to represent conceptual database as viewed by end user ERD’s main components: Entities Relationships Includes connectivity and cardinality notations Connectivities and cardinalities are based on business rules In ERD, M:N relationship is valid at conceptual level
Create an ERD for the following: A department employs many employees, but each employee is employed by one department. A division operates many departments, but each department is operated by one division. An employee may be assigned to many projects, and a project may have many employees assigned to it.
Create an ERD for the following: Identify the entities Draw the ERD showing relationships A Librarian wishes to make inquiries about borrowing activity within a library. The librarian can inquire about specific books borrowed by a customer using either their account or name. An inquiry can also be made by book category (such as fantasy, children’s, reference, etc) or an inquiry can be made that will look at the titles of a specific book.
Create an ERD for the following: Identify the entities Draw the ERD showing relationships Multiple Real Estate Listing Service (MRELS) is a company that has offices throughout Southern Ontario. These offices have a number of Real Estate agents working for them. MRELS deals in both residential and commercial real estate. Agents work with customers to get a listing or to find a listing for a customer. A listing will include the address and the type of property (residential or commercial), square footage, annual taxes and closing date. If it is a residential property, it will include number of bedrooms, number of bathrooms, special features (central air, heated by gas or oil, radiators or forced air, for instance). For a commercial property, it will include number of offices as well as number of docking bays (where trucks back up to be loaded/unloaded).