Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture # 6.  A class of data models  Conveys semantic meaning  Implements databases more intelligently  Support more sophisticated user interfaces.

Similar presentations


Presentation on theme: "Lecture # 6.  A class of data models  Conveys semantic meaning  Implements databases more intelligently  Support more sophisticated user interfaces."— Presentation transcript:

1 Lecture # 6

2  A class of data models  Conveys semantic meaning  Implements databases more intelligently  Support more sophisticated user interfaces (SQL queries)  Research started in 1970s and early 1980s  Other names are data modeling, E/R modeling, E-modeling

3  Design methodologies that are based on semantic modeling ideas are often referred to as Top-Down methodologies, because they start at a high level of abstraction with real world constructs or entities and finish at the low level of abstraction represented by a specific concrete database design

4  Chen in 1976 introduced the E/R model  The E/R model allows us to sketch the design of a database informally.  Designs are pictures called entity- relationship diagrams.  Fairly mechanical ways to convert E/R diagrams to real implementations like relational databases exist.

5 Requirements Analysis Conceptual Design Logical Design Database Building Operation, Mainte- nance, & Tuning Requirements Specification Conceptual Model Relational Model Database Evolving Database Natural Language Informal Formal Physical DBMS-specific DBMS-independent

6  Requirements Analysis  Collect and Analyze the requirements of the users.  Conceptual Design  Design a conceptual model (schema), e.g., ER model.  Logical Design  Translate the ER model into a relational model (schema).  Normalization  Database Building  Build the database and write application programs.  Operation, Maintenance, & Tuning  Use, maintain, and “tune” the database.

7  Most systems development efforts follow a classical Systems Development Life Cycle.  1. Project Identification - preliminary analysis of needs.  2. Project Initiation and Planning - identifies possible approaches to solving the business need.  3. Analysis - identify the functional specifications for the business needs - continue to confirm that the project is feasible.  4. Logical Design - detailed functional specifications in the form of screen designs, report layout designs, data models, processing rules, etc.  5. Physical Design - programming, development of physical data structures, redesigning parts of the organization to support the new system.  6. Implementation - sometimes includes testing or testing may be part of physical design. Includes a plan to cut over to the new system.  7. Maintenance - continued modification of the system as the firm's needs change.

8  This is the concept that there are different levels or views of the data that the firm uses.  Level 0--Reality. This is the actual real data that managers use.  Level 1--Conceptual Schema - also called a Conceptual Model.  This model is developed during the analysis stage of system development.  Typically this is some type of diagramming model of the data and the relationships among the data. It is an abstractions of reality to focus on the data the firm uses for specific applications.  Entity-Relationship Diagrams capture overall structure of the organization's data  Level 2--External Schema -- also termed a Logical Model.  This model is developed during the design stage and represents the actual implementation of the conceptual model with a specific DBMS product.  This includes table design and the application of rules for Normalization of data and translating conceptual model into relations.  Level 3--Physical or Internal Schema.  This is created during the physical design and implementation phase.  It includes the actual storage of data, creation of files that comprise the database including indexes and other structures

9  Translate an ER schema into a relational schema.  Entity  Relationship  Attribute  Subtype  Normalization  To ensure you have a “good” design.

10 Meaning ENTITY TYPE WEAK ENTITY TYPE RELATIONSHIP TYPE IDENTIFYING RELATIONSHIP TYPE ATTRIBUTE KEY ATTRIBUTE MULTIVALUED ATTRIBUTE COMPOSITE ATTRIBUTE DERIVED ATTRIBUTE TOTAL PARTICIPATION OF E 2 IN R CARDINALITY RATIO 1:N FOR E 1 :E 2 IN R STRUCTURAL CONSTRAINT (min, max) ON PARTICIPATION OF E IN R Symbol E1E1 R E2E2 E1E1 R E2E2 R (min,max) E N

11  Requirements of the Company (over) simplified:  The company is organized into DEPARTMENTs.  Each department has a name, number and an employee who manages the department.  We keep track of the start date of the department manager.  Each department controls a number of PROJECTs.  Each project has a name, number and is located at a single location.

12  We store each EMPLOYEE’s social security number, address, salary, gender, and birthdate.  Each employee works for one department but may work on several projects.  We keep track of the number of hours per week that an employee currently works on each project.  We keep track of each employee’s direct supervisor.  Each employee may have a number of DEPENDENTs.  For each dependent, we keep track of their name, gender, birthdate, and relationship to employee.

13

14 Employee department Project Works For Supervision Controls Dependents manages Works-on Location Number Name Hours Name RelationshipBdateGender Name SSN Salary Name location No-Emp Addr Dependent 1 N N M N N 1 1 1 DNumber 1 N

15  Participation constraint (double line for total) e.g. If N employees work for 1 department, put N on line from employee to works_for and 1 on line from department to works_for If must work for a department, double line, else single line

16  An Entity is something about which we store data for use by managers and workers. An entity can be either an item found in reality or an abstract concept.  Person: EMPLOYEE, STUDENT, PATIENT  Place: CITY, DEPARTMENT  Object: MACHINE, BUILDING, AUTOMOBILE  Event: CUSTOMER_ORDER, INVENTORY_RENEWAL  Concept: ACCOUNT, COURSE, WORK_CENTER

17  Entities - are specific objects or things in the mini- world that are represented in the database; for example, the EMPLOYEE John Smith, the Research DEPARTMENT, the ProductX PROJECT  Attributes are properties used to describe an entity; for example, an EMPLOYEE entity may have a Name, SSN, Address, gender, BirthDate  A specific entity will have a value for each of its attributes; for example, a specific employee entity may have Name=‘John Smith’, SSN=‘123456789’, Address=‘731 Fondren, Houston, TX’, Gender=‘M’, BirthDate=‘09-JAN-75’

18  Domain: Possible values for an attribute; for example ‘M’ and ‘F’ for the Gender attribute. What could be possible domain for Location???  Simple: Each entity has a single atomic value for the attribute; for example SSN, Gender and name. IS ADDRESS IS ATOMIC??  Composite: The attribute may be composed of several components; for example, Address (Apt#, House#, Street, City, State, ZipCode, Country) or Name(FirstName, MiddleName, LastName). Composition may form a hierarchy where some components are themselves composite.

19  Multi-valued: An entity may have multiple values for that attribute; for example, Color of a CAR or PreviousDegrees of a STUDENT. Denoted as {Color} or {PreviousDegrees}.  Porject  Location  In general, composite and multi-valued attributes may be nested arbitrarily to any number of levels although this is rare. For example, PreviousDegrees of a STUDENT is a composite multi-valued attribute denoted by {PreviousDegrees(College, Year, Degree, Field)}.

20  Entities with the same basic attributes are grouped or typed into an entity type. For example, the EMPLOYEE entity type or the PROJECT entity type.  An attribute of an entity type for which each entity must have a unique value is called a key attribute of the entity type. For example, SSN of EMPLOYEE.

21  A key attribute may be composite. For example, VehicleTagNumber is a key of the CAR entity type with components (Number, State).  An entity type may have more than one key. For example, the CAR entity type may have two keys:  VehicleIdentificationNumber (popularly called VIN) and  VehicleTagNumber (Number, State), also known as license_plate number.

22  A relationship relates two or more distinct entities with a specific meaning; for example, EMPLOYEE John Smith works on the ProductX PROJECT or EMPLOYEE Franklin Wong manages the Research DEPARTMENT.  Relationships of the same type are grouped or typed into a relationship type. For example, the WORKS_ON relationship type in which EMPLOYEEs and PROJECTs participate, or the MANAGES relationship type in which EMPLOYEEs and DEPARTMENTs participate.

23  The degree of a relationship type is the number of participating entity types. Both MANAGES and WORKS_ON are binary relationships.  More than one relationship type can exist with the same participating entity types; for examples, MANAGES and WORKS_FOR are distinct relationships between EMPLOYEE and DEPARTMENT participate.

24 EMPLOYEEPROJECT WORKS_ON EMPLOYEEDEPARTMENT MANAGES EMPLOYEEDEPARTMENT MANAGES WORKS_FOR Hours

25  A relationship can relate two entities of the same entity type ; for example, a SUPERVISION relationship type relates one EMPLOYEE (in the role of supervisee ) to another EMPLOYEE (in the role of supervisor ). This is called a recursive relationship type  A relationship type can have attributes; for example, HoursPerWeek of WORKS_ON; its value for each relationship instance describes the number of hours per week that an EMPLOYEE works on a PROJECT.

26 Employee Supervision 1 N

27  Structural constraints on relationships:  Cardinality ratio (of a binary relationship):  1:1, 1:N, N:1, or M:N.  Participation constraint  (on each participating entity type): total (called existence dependency ) or partial.

28  Constraints on Relationship Types  ( Also known as ratio constraints )  Maximum Cardinality  One-to-one (1:1)  One-to-many (1:N) or Many-to-one (N:1)  Many-to-many  Minimum Cardinality (also called participation constraint or existence dependency constraints)  zero (optional participation, not existence-dependent)  one or more (mandatory, existence-dependent)

29  Structural constraints on relationships:  Cardinality ratio (of a binary relationship):  1:1, 1:N, N:1, or M:N.  Participation constraint  (on each participating entity type): total (called existence dependency ) or partial.

30  Express the number of entities to which another entity can be associated via a relationship set.  Most useful in describing binary relationship sets.  For a binary relationship set the mapping cardinality must be one of the following types:  One to one  One to many  Many to one  Many to many

31 One to oneOne to many

32 Many to oneMany to many Note: Some elements in A and B may not be mapped to any elements in the other set

33 Total participation (indicated by double line): every entity in the entity set participates in at least one relationship in the relationship set E.g. participation of loan in borrower is total every loan must have a customer associated to it via borrower Partial participation: some entities may not participate in any relationship in the relationship set E.g. participation of customer in borrower is partial

34 What is this?

35 l Specified on each participation of an entity type E in a relationship type R l Specifies that each entity e in E participates in at least min and at most max relationship instances in R l Default(no constraint): min=0, max=n l Must have min  max, min  0, max  1 l Derived from the knowledge of mini-world constraints Examples: l A department has exactly one manager and an employee can manage at most one department. – Specify (0,1) for participation of EMPLOYEE in MANAGES – Specify (1,1) for participation of DEPARTMENT in MANAGES l An employee can work for exactly one department but a department can have any number of employees. – Specify (1,1) for participation of EMPLOYEE in WORKS_FOR – Specify (0,n) for participation of DEPARTMENT in WORKS_FOR

36 The (min,max) notation for higher order relationship type constraints (1,1) (0,1) (1,N) (1,1) (exactly) (can)

37 The (min,max) notation for higher order relationship type constraints A Teacher can offer min 1 and max 2 Offerings A Course may have 1 to 3 Offerings A Student may enroll in from 1 to 5 Offerings (1,5) (1,3) (1,2)

38 l Relationship types of degree 2 are called binary l Relationship types of degree 3 are called ternary and of degree n are called n-ary

39 © The Benjamin/Cummings Publishing Company, Inc. 1994, Elmasri/Navathe, Fundamentals of Database Systems, Second Edition

40 SUPPLIER SName SUPPLY PROJECT Quality PART PartNo ProjName

41 SUPPLIER SName SUPPLY PROJECT PART PartNo ProjName MN CAN_SUPPLYUSES M M N N

42 SUPPLIER SName SS PROJECT PART PartNo ProjName 1N SUPPLY N Quantity SPJ N1 SP N 1

43 © The Benjamin/Cummings Publishing Company, Inc. 1994, Elmasri/Navathe, Fundamentals of Database Systems, Second Edition

44

45

46  An entity that does not have a key attribute  A weak entity must participate in an identifying relationship type with an owner or identifying entity type  Entities are identified by the combination of:  A partial key of the weak entity type  The particular entity they are related to in the identifying entity type Example: Suppose that a DEPENDENT entity is identified by the dependent’s first name and birthdate, and the specific EMPLOYEE that the dependent is related to. DEPENDENT is a weak entity type with EMPLOYEE as its identifying entity type via the identifying relationship type DEPENDENT_OF

47  A student has a name, which consists of a given name and a family name, and a student ID. Each student is uniquely identified by his/her student ID.  A course has a subject and a course ID and the type of equipment being used for the course. For each course, we want to record the number of students taking that course. A course is uniquely identified by its course ID.  A student can be enrolled in an arbitrary number of courses, and an arbitrary number of students can be enrolled in a course. For each course in which they are enrolled students receive a lab mark and an exam mark.  A course cannot exist if there is no student enrolled in it.  A school is distinguished by the honour's degree that it awards. We also want to record to which faculty a school belongs. A student is registered with at most one school, while a school can have an arbitrary number of students.

48  A student is also registered for a year of study. A year of study is identified by a number between 1 and 4. A student is registered for only one year of study, but each year can have many students.  For each member of staff we want to record their name and their room number. A member of staff is identified by the combination of these two pieces of data. Staff are appraised by other staff. A member of staff has no more than one appraiser.  Students can be allocated to a member of staff as their tutor. A student can have no more than one tutor. The tutor and the student agree upon a time slot for regular meetings.  For each year of study, there must be one member of staff who acts as the year tutor. A member of staff can only be responsible for one year of study. Students can be registered for a year of study.  Courses are taught by members of staff. A course can have several teachers, and a staff member can teach several courses.

49 That’s it for today!!!


Download ppt "Lecture # 6.  A class of data models  Conveys semantic meaning  Implements databases more intelligently  Support more sophisticated user interfaces."

Similar presentations


Ads by Google