Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.

Similar presentations


Presentation on theme: "Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented."— Presentation transcript:

1 Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented in relational modeling. Data Models Notations ( Chens and Crows Foot notation) Classification Of Attributes. How to identify candidate,primary and foreign key and alternate keys. Combining the different datasets and represent them as a data model.. 1

2 Data modeling using the entity-relationship model Database Systems@ucu2 In this Chapter, we describe the main techniques for gathering and capturing information about what the users require of a database system. One of the most difficult aspects of database design is the fact that designers, database designers and end-users tend to view data and its use in different ways. Unfortunately unless we get a common understanding that reflects how the enterprise operates the design we produce will fail to meet the user requirements. We need to get a model for communication that is non-technical and free of ambiguities.

3 Data modeling using the entity-relationship model Database Systems@ucu3 Entity-relationship model (ER model) ER model: Is used to create a Conceptual /theoretical data model that reflects all the user data requirements. It includes detailed descriptions of entity types, relationships, and Constraints. It is majorly used for communication with non- technical users

4 Data modeling using the entity-relationship model ERD Development Process i). Identity the Entities. ii).Determine the attributes for each entity. iii).Select the primary key for each entity. iv).Establish the relationship between the entities. v).Draw an Entity model 4 Database Systems@UCU

5 Data modeling using the entity-relationship model Database Systems@ucu5 1. Entities. An entity can be classified in one of the following categories. Strong entity - An entity type is strong if its existence does not depend on some other entity type Weak entity: Is an entity that is dependant on the existence of another entity. It cannot be uniquely identified by its attributes alone. Does not have a key of its own - It’s identified by being related to another (Strong) entity type using some of their attribute values. It’s main characteristics - identifying owner - identifying relationship - Does not have a key of its own

6 Data modeling using the entity-relationship model 2. Determine the Attributes Every Entity has Attributes. Attributes are characteristics that allow users to classify / describe an entity. Attribute Domain –Set of allowable values for one or more attributes. For example the attribute GPA is written (0,5). The domain for an attribute Gender consists of only 2 possibilities M or F. Eg An Entity student has the attributes. - Student number -Name -Date of Birth -Course Number 6 Database Systems@UCU

7 Data modeling using the entity-relationship model Database Systems@ucu7 Concepts (you should understand) Attribute classification Simple attribute Composite Attribute Single Valued Attribute multi valued attribute Derived Attribute Key attribute: Candidate Key, Primary Key, Alternate Key. Null values: not applicable, unknown, missing.

8 Data modeling using the entity-relationship model Database Systems@ucu8 Attributes Simple Attribute –Attribute composed of a single component with an independent existence. Simple attributes cannot be further subdivided into smaller components. Eg age, marital status. Composite Attribute -Some attributes can be further divided to yield smaller components with independent existence. –Attribute composed of multiple components, each with an independent existence. Eg Address ( 163 main st, Glasgow, G11 9QX) can be divided in to Street, city and postcode, DOB

9 Data modeling using the entity-relationship model Database Systems@ucu9 Attributes Single-valued Attribute –Attribute that holds a single value for each occurrence of an entity type. Eg ? ? Multi-valued Attribute –Attribute that holds multiple values for each occurrence of an entity type. Eg?? Derived Attribute –Attribute whose value is calculated from other attributes. The derived attribute need not be physically stored within the database. –Eg Employee age can be found by computing an integer value difference of Current Date- DOB=

10 Data modeling using the entity-relationship model 10 Keys Certain attributes identify particular facts with an entity, these are known as KEY attributes. Candidate Key –Minimal set of attributes that uniquely identifies each occurrence of an entity type. Primary Key –Field that is selected to uniquely identify each occurrence of an entity type. Alternate Key Candidate keys that are not selected as the primary key

11 Data modeling using the entity-relationship model Naming and Defining Relationships A relationship is an association between entities. Relationship name is a verb phrase. Guidelines for defining relationships. Definition explains what action is being taken and why it is important. eg Supervises or manages 11 Database Systems@UCU

12 Data modeling using the entity-relationship model Database Systems@ucu12 A recursive association connects a single class type (serving in one role) to itself (serving in another role). Recursive Relationship Relationship type where same entity type participates more than once in different roles

13 Data modeling using the entity-relationship model Database Systems@ucu13 Relationship Types Degree of a Relationship –Number of participating entities in relationship. Relationship of degree : –two is binary –three is ternary –four is quaternary.

14 Data modeling using the entity-relationship model Database Systems@ucu14 Relationship Types Degree of a Relationship –Number of participating entities in relationship. Relationship of degree : –two is binary –three is ternary –four is quaternary.

15 Data modeling using the entity-relationship model Database Systems@ucu15 Binary relationship called Has

16 Data modeling using the entity-relationship model Database Systems@ucu16 Ternary relationship called Registers

17 Data modeling using the entity-relationship model Database Systems@ucu17 Quaternary relationship called Arranges

18 Data modeling using the entity-relationship model Cardinality of a Relationship. Describes maximum number of possible relationship occurrences for an entity participating in a given relationship type. In ERD cardinality is indicated by placing the appropriate numbers beside the entities using the format ( x,y). x – minimum value, y – Maximum Value An example of a one to many relationship is when an employee can work for only one department, and a department can have many employees 18 Database Systems@UCU

19 Data modeling using the entity-relationship model Database Systems@ucu19 Consider some instances department employs instructor d1 d2 d3 e1 e2 e3 e4 e5 e6 e7

20 Data modeling using the entity-relationship model Many to Many relationship: Is a key constraint that indicates that many of one entity can be associated with many of another entity. An example of many to many relation is employees and their hobbies: A person can have many different hobbies and many people can have the same hobby. Database Systems@UCU 20

21 Data modeling using the entity-relationship model Database Systems@ucu21 Example The company database keeps track of a company’s employees, departments, and projects: Requirements: concerning the department: 1.company is organized into departments 2.a department has a unique name, a unique number, and a specific employee is its’ manager 3.we track the start date for the manager function 4.a department may be in several locations 5.a department controls a number of projects concerning the project: 6.a project has a unique name, a unique number, and a location

22 Data modeling using the entity-relationship model Database Systems@ucu22 example continued concerning the employee: 7.each employee has a name, social insurance number, address, salary, sex, and birth date 8.an employee is assigned to one department but may work on several projects which are not necessarily controlled by the same department 9.we track the number of hours per week that an employee works on each project 10.we keep track of the direct supervisor of each employee 11.we track the dependents of each employee (for insurance purposes) concerning the dependent: 12.we record each dependent’s first name, sex, birth date, and relationship to the employee

23 Data modeling using the entity-relationship model Basic ERD symbols Entity Attribu te Multi Valued Attribute Relationsh ip Derived attribute Derived Attribute 23 Database Systems@UCU

24 Data modeling using the entity-relationship model Database Systems@ucu24 The entities/Relations: employee department project dependent

25 Data modeling using the entity-relationship model Database Systems@ucu25 The entities/Relations: bdate ssn namesex address salary birthdatenamesex relationship name numberlocation name numberlocation employee department project dependent

26 Data modeling using the entity-relationship model Database Systems@ucu26 With relationships: employee department project dependent works for manages works on dependents of controls supervision 1 N N 1 NM 1 N 1 1 N 1 supervisor supervisee

27 Data modeling using the entity-relationship model Database Systems@ucu27 Relationships Degree of a relationship Recursive relationship Constraints cardinality: m-n, 1-n, 1-1 Relationships are always labeled with verb phrases. PROFESSOR teaches a CLASS, BRANCH has STAFF. Concepts (you should understand)

28 Data modeling using the entity-relationship model Database Systems@ucu28 Let’s consider a university environment: At a high level, we need to: offer courses register students assign instructors to courses assign grades anything else?

29 Data modeling using the entity-relationship model Database Systems@ucu29 Instructors: let’s assume this classification includes instructors, professors, part-time people (at least for now). These people have SINs ( social insurance number), employee numbers, names, addresses, offices, phones,... instructor SIN office address employee no name phonedegree

30 Data modeling using the entity-relationship model Database Systems@ucu30 instructor SIN office address employee no name phone Is there a key attribute? What are the domains? Can any attribute be null? Is any attribute composite, derived, multivalued? Is this a weak entity or a strong entity? Should department be an attribute? degree

31 Data modeling using the entity-relationship model Database Systems@ucu31 Departments: obviously instructors are employed by the University and associated with a department A department has a name, number, office, chair(head of dept),... department Dnumber chair phone name office

32 Data modeling using the entity-relationship model Database Systems@ucu32 department Dnumber chair phone name office Should chair be an attribute, or is there a relationship between two entity types? Is there a key attribute? What are the domains? Can any attribute be null? Is any attribute composite, derived, multivalued?

33 Data modeling using the entity-relationship model Database Systems@ucu33 department Employs relationship: If we assume the relationship between department and instructor is 1:N. We associate any number of instructors with a single department instructor employs 1N 1:N is the cardinality of the relationship the relationship is of degree 2; it is a binary relationship

34 Data modeling using the entity-relationship model Database Systems@ucu34 CONCLUSION The whole point about this chapter is “Given a dataset, how does one comeup with (i.e Design and formulate) entities and relationships and cardinalities between the different entities based on the business processes and needs of the organisation for which they are designing the database.


Download ppt "Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented."

Similar presentations


Ads by Google