Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Database Collection of data in electronic format – A digital library of organization Managed.

Similar presentations


Presentation on theme: "Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Database Collection of data in electronic format – A digital library of organization Managed."— Presentation transcript:

1 Data Modeling Yong Choi School of Business CSUB

2 Part # 2 2 Database Collection of data in electronic format – A digital library of organization Managed by one set of software that provides access to all the data No data redundancy, data inconsistency, poor security, application-data dependency...

3 Part # 2 3 Database Management System (DBMS) Database software Act as an interface between application and physical data files Support centralization of data Independent of specific computer programs small (MS Access), large/popular (Oracle)

4 Part # 2 4 Database Models Hierarchical (Tree) Models Network Model Relational Models

5 Part # 2 5 Relational Database Model In the relational data model the database is represented as a group of related tables. The relational data model was introduced in 1970 by E. F. Codd of IBM published a paper in CACM entitled "A Relational Model of Data for Large Shared Data Banks". It is currently the most popular model. The mathematical simplicity and ease of visualization of the relational data model have contributed to its success.

6 Part # 2 6 Relational Database A schematic diagram of a relational database (a) and a sample part of a relational database showing different tables (b)

7 Part # 2 7 Relational database and keys A relational database is a collection of tables that are related to one another based on a common field. A field, or a collection of fields, is designated as the primary key. The primary key uniquely identifies a record in the table. When the primary key of one table is represented in a second table to form a relationship, it is called a foreign key.

8 Part # 2 8 Primary Key Unique identifier – Last name vs. SS# Prevent confusion Cost of PK – SS# vs. finger print – Entity Integrity Rule Any primary key is allowed to accept null values.

9 Part # 2 9 Foreign Key An attribute in one table whose values must either match the primary key in another table or be null. The database must not contain any unmatched foreign key values.

10 Part # 2 10 Foreign Keys Student ID Last Name First Name Dor m 2144ArnoldBettySmit h 3122TaylorJohnJone s 3843SimmonsLisaSmit h 9844MacyBill 2837LeathHeatherSmit h 2293WrenchTimJone s DormResidence Director SmithAndrea Fernandez JonesDaniel Abidjan Primary Key Foreign Key Duplicated from primary key of Major entity (not unique)

11 Part # 2 11 Foreign Keys

12 Part # 2 12 Relating tables using a common field The primary key in the Employer table (EmployerID) is the common field that relates this table to the Position table. PositionID is the primary key in the Position table. The EmployerID field is a foreign key in this table. Primary keys can only have one occurrence in a table. Foreign keys may have multiple occurrences.

13 Part # 2 13 Why Conceptual Data Modeling is Important? Effective Communication Tool User involvement Independence from a particular DBMS Documentation

14 Part # 2 14 Entity Relationship diagram (ERD) ERD is commonly used to: Translate different views of data among managers, users, and programmers to fit into a common framework. Define data processing and constraint requirements to help us meet the different views. Help implement the database. Developed by Peter Chen (1976).

15 Part # 2 ERD using Chen’ Notation

16 Part # 2 16 ER model using IE Notation

17 Part # 2 17 Basic Entity Relationship Diagram (ERD) Elements Entity : a collection of people, places, objects, events, concepts of interest (a table) Entity instance – a member of the Entity : a person, a place, an object … (a row in a table) Attribute - property or characteristic of interest of an entity (a field in a table) Relationship – association between entities (corresponds to primary key-foreign key equivalencies in related tables)

18 Part # 2 18 Entity What should be an Entity: An object that will have many instances in the database An object that will be composed of multiple attributes An object that we are trying to model What should NOT be an Entity: A user of the database system An output of the database system (e.g. a report)

19 Part # 2 19 Inappropriate entities System user System output Appropriate entities Entity …

20 Part # 2 20 Entity Instance Entity instance: a single occurrence of an entity. Student ID Last Name First Name 2144ArnoldBetty 3122TaylorJohn 3843SimmonsLisa 9844MacyBill 2837LeathHeather 2293WrenchTim instance entity

21 Part # 2 21 “describe the entity’s characteristics” Attributes are represented by an Ellipse/Oval connected to the entity with a line by Chen’s notation. Each oval contains the name of the attribute it represents. Entity: Employee Attributes:Employee-Name, Extension, Date-Of-Hire, Job-Skill-Code Attributes

22 Part # 2 ERD using Chen’ Notation

23 Part # 2 23 Classes of attributes Simple Attribute Composite Attribute Derived Attributes Single-valued Multi-valued Attribute

24 Part # 2 24 How to find entities and attributes?? Entity: a collection of people, places, objects, events, concepts of interest look for nouns Usually, a proper noun is not a good candidate…. Attribute: property or characteristic of interest of an entity look for attribute descriptive words

25 Part # 2 25 “attributes that uniquely identify entity instances” Uniquely identify every instance of the entity Composite identifiers are identifiers that consist of two or more attributes Entity:Employee Identifier:Social-Security-Number (unique) Identifier

26 Part # 2 26 Entities??? ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost. Also the organization would like to store the date the chemist was assigned to the project and the date an equipment item was assigned to a particular chemist working on a particular project. A chemist must be assigned at least to one project and one equipment item. Any given equipment item need not be assigned, and a given project need not be assigned either a chemist or an equipment item.

27 Part # 2 27 Entities Chemist Project Equipment

28 Part # 2 28 Attributes??? ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost. Also the organization would like to store the date the chemist was assigned to the project and the date an equipment item was assigned to a particular chemist working on a particular project. A chemist must be assigned at least to one project and one equipment item. Any given equipment item need not be assigned, and a given project need not be assigned either a chemist or an equipment item.

29 Part # 2 29 Entities & Attributes Project Proj# Start-Date Chemist Phone# Emp# Equipment Serial# cost How many attributes do you (as a entity of our school database) have? – name your attributes

30 Part # 2 30 Example 1: find entities A department hires many employee. A employee is employed by one department. A manager manages one department. A department is managed by one manager. A person must have only one DNA pattern and that pattern must be applied to only one person.

31 Part # 2 31 Example 2: find entities There are several departments in School of Business and Public Administration at CSUB. Each department belongs to one school. A department has many professors, but a professor may belong to more than one department. Similarly, courses may be offered by several departments and a department must have at least one course. A professor may teach more than one student, and a student may have more than one professor.

32 Part # 2 32 Example 4: Find all entities, attributes, and (unique) identifier The FANTASTIC video rental company has several branches throughout the USA. The data held on each branch is the branch address made up of street, city, state, and zip code, and the telephone number. Each branch is given a branch number, which is unique throughout the company. Each branch is allocated staff, which includes a Manager. The Manager is responsible for the day-today running of a given branch. The data held on a member of staff is his or her name, position, and salary. Each member of staff is given a staff number, which is unique throughout the company. Each branch has a stock of videos. The data held on a video is the catalog number, video number, title, category, daily rental, cost, status, and the names of the main actors, and the director. The catalog number uniquely identifies each video.

33 Part # 2 33 Example 4: Find all entities, attributes, and (unique) identifier (con’t) A customer must first register as a member of a local branch before renting a video tape from any branches. The data held on a member is the first and last name, address, and the date that the member registered at a branch. Each member is given a member number, which is unique throughout all branches of the company. Once registered, a member is free to rent videos, up to maximum of ten at any one time. The data held on each video rented is the rental number, the full name and number of the member, the video number, title, and daily rental, and the dates the video is rented out and date returned. The rental number is unique throughout the company.

34 Part # 2 34 Relationships Association between entities (by lines) Any connected entities are called participants Operate in both directions Relationship between Student and Curriculum A student is enrolled in many curriculums. Each curriculum is being studied by many students.

35 Part # 2 35 Relationships ??? ANG Laboratory has several chemists who work on one or more projects. Chemists also may use certain kinds of equipment on each project. The organization would like to store the chemist’s employee identification number, his/her name, up to three phone numbers, his/her project identification number and the date on which the project started. Every piece of equipment, the chemist uses, has a serial number and a cost. Also the organization would like to store the date the chemist was assigned to the project and the date an equipment item was assigned to a particular chemist working on a particular project. A chemist must be assigned at least to one project and one equipment item. Any given equipment item need not be assigned, and a given project need not be assigned either a chemist or an equipment item.

36 Part # 2 36 Entities/Relationships & their Attributes Chemist Phone# Project Proj# Start-Date Equipment Works-On Uses Date-Assigned Emp# Serial# cost Assign-Date

37 Part # 2 37 Steps for creating an ERD Develop draft business rules Using interviews and documents Identify the entities (look for nouns) Identify the attributes (look for attribute descriptive words) identify draft business rules Identify the relationships (look for verb or verb phrases between entities) Identify cardinalities (look for participation related words and phrases such as zero, none, a, one, several, many…..) Optional (look for auxiliary verbs such as may, might, can and based upon own judgment..) Set business rules

38 Part # 2 38 Cardinality of Relationship One – to – One (1:1) Each instance in the relationship will have exactly one related member on the other side One – to – Many (1:M) A instance on one side of the relationship can have many related members on the other side, but a member on the other side will have a maximum of one related instance Many – to – Many (M:N) Instances on both sides of the relationship can have many related instances on the other side

39 Part # 2 39 1:1 relationship in set notation

40 Part # 2 40 Example of 1:1 relationship A one-to-one (1:1) relationship is when at most one instance of a entity A is associated with one instance of entity B. Each employee has a one’s own office. Cardinality toward the Office entity Each office is occupied by one employee. Cardinality toward the Employee entity

41 Part # 2 41 1:1 relationship A person must have one and only one DNA pattern and that pattern must apply to one and only one person.

42 Part # 2 42 1:M relationship in set notation

43 Part # 2 43 Example of 1:M relationship A one-to-many (1:N) relationships is when for one instance of entity A, there are zero, one, or many instances of entity B, but for one instance of entity B, there is only one instance of entity A. Each employee has many offices. Cardinality toward the Office entity Each office is occupied by one employee. Cardinality toward the Employee entity

44 Part # 2 44 1:M relationship Each department hires many employees, and each employee is hired by one department.

45 Part # 2 45 M:N relationship in set notation

46 Part # 2 46 Example of M:N relationship A many-to-many (M:N) relationship, sometimes called non-specific, is when for one instance of entity A, there are zero, one, or many instances of entity B and for one instance of entity B there are zero, one, or many instances of entity A. A employee has multiple offices. Cardinality toward the Office entity A office must be occupied by many employee. Cardinality toward the Employee entity

47 Part # 2 47 M:N relationship Each student takes many classes, and each class is taken by many students. ** This is not a desirable relationship.** STUDENT CLASS TAKE IS_TAKEN_BY

48 Part # 2 48 Complete ER Diagram Chemist Phone# Project Proj# Start-Date Equipment Works-On Uses Date-Assigned N 1 N1 Emp# Serial# cost Assign-Date

49 Part # 2 49 Cardinality Notations Cardinality Interpretation Minimum Instances Maximum Instances Graphic Notation Exactly one Zero or one One or many Zero or many 1 1 0 0 1 1 Many (>1)

50 Part # 2 50 Steps for creating an ERD Develop draft business rules Using interviews and documents Identify the entities (look for nouns) Identify the attributes (look for attribute descriptive words) identify draft business rules Identify the relationships (look for verb or verb phrases between entities) Identify cardinalities (look for participation related words and phrases such as zero, none, a, one, several, many…..) Optional (look for auxiliary verbs such as may, might, can and based upon own judgment..) Set business rules


Download ppt "Data Modeling Yong Choi School of Business CSUB. Part # 2 2 Database Collection of data in electronic format – A digital library of organization Managed."

Similar presentations


Ads by Google