Database Basics Jan. 2010Yangjun Chen ACS-39021 Outline: Database Basics Database system architecture Data modeling Entity-relationship model -Entity types.

Slides:



Advertisements
Similar presentations
Relational Database Design : ER- Mapping
Advertisements

3/25/2017.
Database Design The process of finding user requirement
Week 5 Relational Database Design by ER- -to-Relational Mapping.
the Entity-Relationship (ER) Model
Entity-Relationship (ER) Modeling
1 Database Theoretic Basis Entity Relationship (E-R) Modeling Database Theoretic Basis Entity Relationship (E-R) Modeling.
Jan. 2014Dr. Yangjun Chen ACS Outline (Ch. 17, 3 rd ed. – Ch. 2, 4 th ed., 5 th ed., 6 th ed.) Database System Architectures System Catalog System.
Mapping an ERD to a Relational Database To map an ERD to a relational database, five rules are defined to govern how tables are constructed. 1)Rule for.
Databases and Database Users Sept. 2012Yangjun Chen ACS Outline: Introduction (Chapter 1 – 3 rd, 4 th, 5 th, 6 th ed.) What is a database? The main.
Data modeling using the entity-relationship model Sept. 2012Yangjun Chen ACS Outline: Data modeling using ER-model (Chapter 3 - 3rd, 4th, 5th ed.)
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Data Modeling Using the Entity- Relationship (ER) Model.
Conceptual Models Agenda - Steps in the design of a DB - Need for conceptual models - The Entity-Relationship Model (ER-Model)
ER-to-Relational Mapping Jan. 2012ACS-3902 Yangjun Chen1 ER-to-Relational Mapping Principles Specialization/Generalization -Superclass/Subclass Relationship.
Review Database Application Development Access Database Development ER-diagram Forms Reports Queries.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 7 Relational Database Design by ER- Mapping.
Data modeling using the entity-relationship model Winter 2006Ron McFadyen Entity-relationship model (ER model) P. 49: “This model and its variations.
Class Number – CS 304 Class Name - DBMS Instructor – Sanjay Madria Instructor – Sanjay Madria Lesson Title – ER Model.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas.
Data Modeling Using the Entity-Relationship Model
Data Modeling Using the Entity-Relationship Model
CSE314 Database Systems Data Modeling Using the Entity- Relationship (ER) Model Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
1 DATABASE By Mr. Abdalla A. Shaame.  What is a database?  The main characters of a database system  The basic database design method  The entity-relationship.
Logical DB Design 5. 1 CSE2132 Database Systems Week 5 Lecture Logical Database Design.
Review: Application of Database Systems
SQL Structured Query Language Programming Course.
Chapter 3 Data Modeling Using the Entity- Relationship (ER) Model Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data modeling using the entity-relationship model Chapter 3 Objectives How entities, tuples, attributes and relationships among entities are represented.
Mapping from conceptual model (EER-M)
Logical Design database design. Dr. Mohamed Osman Hegaz2 Conceptual Database Designing –Provides concepts that are close to the way many users perceive.
Entity-Relationship Model Chapter 3 II COSC 457 Sungchul Hong.
Exam 1 Review Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 3 Data Modeling Using Entity-Relationship Model.
An Introduction to Database Systems دانشگاه علم و فناوری مازندران - طراحی و ایجاد بانک های اطلاعاتی 1.
Mapping ER Diagrams to Tables
Database System Architecture and System Catalog
Data Modeling Using the Entity- Relationship (ER) Model
Comp 1100 Entity-Relationship (ER) Model
Relational Database Design by ER- and ERR-to-Relational Mapping
Relational Database Design by ER- and EER-to- Relational Mapping
Entity- Relationship (ER) Model
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
Relational Database Design by ER-to-Relational Mapping
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
9/5/2018.
Lecture3: Data Modeling Using the Entity-Relationship Model.
Chapter (9) ER and EER-to-Relational Mapping, and other Relational Languages Objectives How a relational database schema can be created from a conceptual.
بسم الله الرحمن الرحيم.
Mapping ER Diagrams to Tables
11/15/2018.
Company Requirements.
Outline: Database Basics
Chapter 8: Mapping a Conceptual Design into a Logical Design
EER to Relational Mapping
376a. Database Design Dept. of Computer Science Vassar College
Relational Database Design by ER- and EER-to-Relational Mapping
Relational Database Design by ER- and EER-to- Relational Mapping
Relational Database Design by ER- and EERR-to-Relational Mapping
4/11/2019.
1. Explain the following concepts: (a) superkey (b) key
1.(5) Describe the working process with a database system.
Mapping an ERD to a Relational Database
Relational Database Design by ER- and EER-to-Relational Mapping
1. Explain the following concepts of the ER data model:
Entity Relation Model Tingting Zhang.
Chapter (7) ER-to-Relational Mapping, and other Relational Languages
Mapping an ERD to a Relational Database
7/19/2019.
Relational Database Design by ER-to-Relational Mapping
Presentation transcript:

Database Basics Jan. 2010Yangjun Chen ACS Outline: Database Basics Database system architecture Data modeling Entity-relationship model -Entity types -strong entities -weak entities -Relationships among entities -Attributes - attribute classification -Constraints -cardinality constraints -participation constraints ER-to-Relation-mapping

Database Basics Jan. 2010Yangjun Chen ACS Database system architecture Interface Database management system Operating system Database

Database Basics Jan. 2010Yangjun Chen ACS Interface Database client Database Database server Database management network Client-server Computer Architecture

Database Basics Jan. 2010Yangjun Chen ACS Client-Server Computer Architecture -Terminals are replaced with PCs and workstations -Mainframe computer is replaced with specialized servers (with specific functionalities). File server, DBMS server, mail server, print server, … Client Print serverFile serverDBMS server …... network

Database Basics Jan. 2010Yangjun Chen ACS Client-server database System Architectures client site1 client site2 server site3 client site n server Communication network …...

Database Basics Jan. 2010Yangjun Chen ACS Client-Server database system architecture -database client user interface, application programs -database server SQL language, transaction management -database connection ODBC - open database connectivity API - application programming interface

Database Basics Jan. 2010Yangjun Chen ACS Client-server database system architecture -database client user interface, data dictionary functions, DBMS interaction with programming language compiler, global query optimization, structuring of complex objects from the data in the buffers,... -database server data storage on disk, index mechanism, local concurrency control and recovery, buffering and caching of disk storage,...

Database Basics Jan. 2010Yangjun Chen ACS Data dictionary – system catalog (meta data) -relation names, attribute names, attribute domains (data types) -description of constraints primary keys, secondary keys, foreign keys, NULL/NON-NULL, cardinality constraints, participation constraints,... -views, storage structure, indexes -security, authorization, owner of each relation

Database Basics Jan. 2010Yangjun Chen ACS Catalog is stored as relations. (It can then be queried, updated and managed using DBMS software - SQL.) REL_NAME ATTR_NAME ATTR_TYPE MEMBER_OF_PK MEMBER_OF_FK FK_RELATION EMPLOYEEFNAME VSTR15 no EMPLOYEESUPERSSN STR9 noyesEMPLOYEE DNO INTEGER noyesDEPARTMENT... REL_AND_ATTR_CATALOG FNAMELNAMESSNSUPERSSNDNO Employee relation schema:...

Database Basics Jan. 2010Yangjun Chen ACS EXEC SQL DECLARE C1 CURSOR FOR SELECT au_fname, au_lname FROM authors FOR BROWSE; EXEC SQL OPEN C1; while (SQLCODE == 0) { EXEC SQL FETCH C1 INTO :fname, :lname; } Illustration for DBMS interaction with programming language compiler:

Database Basics Jan. 2010Yangjun Chen ACS Working process with DBMS Definition record structure data elements names data types constraints etc Construction create database files populate the database with records Manipulation querying updating

Database Basics Jan. 2010Yangjun Chen ACS Entity-relationship model (ER model) ER model: is used to create a conceptual data model that reflects all the user data requirements. It includes detailed descriptions of entity types, relationships, and constraints no implementation details. So it can be used for communication with non-technical users

Database Basics Jan. 2010Yangjun Chen ACS employee department project dependent Example: works for manages works on dependents of controls supervision bdate ssn name lname minit fname sex address salary birthdatenamesex relationship name numberlocation name numberlocation number of employees startdate hours N supervisor supervisee M N 1 1 N N degree 1 N partial constraint total constraint

Database Basics Jan. 2010Yangjun Chen ACS Entities entity type – logical object (concept), physical object strong entity -key attribute – uniquely identifies an individual entity -entity has a key attribute or a combination of attributes which can be used as a key. weak entity No key attributes. Entities belonging to a weak entity type are identified by being related to specific entities from another entity type in combination with some of their attribute values. - identifying owner - identifying relationship - partial key

Database Basics Jan. 2010Yangjun Chen ACS The entities: employee department project dependent

Database Basics Jan. 2010Yangjun Chen ACS The entities: bdate ssn name lname minit fname sex address salary birthdate name sex relationship name numberlocation name numberlocation employee department project dependent strong entity type weak entity type

Database Basics Jan. 2010Yangjun Chen ACS Attribute – property of an entity type Attribute classification atomic attribute multivalued attribute composite attribute complex (nested) attributes Attribute storage stored & derived attribute null values not applicable, unknown, missing key attribute Domain From a domain, an attribute takes its values. data type

Database Basics Jan. 2010Yangjun Chen ACS Attribute classification atomic attribute name numberlocation department Multivalued attribute employee degree composite attribute Complex attribute name lname minit fname employee stored & derived attribute department number of employees department Employees not often used in practice

Database Basics Jan. 2010Yangjun Chen ACS Relationships - degree of a relationship - recursive relationship - role names - constraints cardinality: m:n, 1:n, 1:1 participation (existence dependency) : partial – all the entities take part in a relationship total – all the entities take part in a relationship

Database Basics Jan. 2010Yangjun Chen ACS 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 is in a single location

Database Basics Jan. 2010Yangjun Chen ACS 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

Database Basics Jan. 2010Yangjun Chen ACS The entities: employee department project dependent

Database Basics Jan. 2010Yangjun Chen ACS The entities: bdate ssn name lname minit fname sex address salary birthdatenamesex relationship name numberlocation name numberlocation employee department project dependent

Database Basics Jan. 2010Yangjun Chen ACS 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 partial constraint total constraint

Database Basics Jan. 2010Yangjun Chen ACS employee department project dependent Example: works for manages works on dependents of controls supervision bdate ssn name lname minit fname sex address salary birthdatenamesex relationship name numberlocation name numberlocation number of employees startdate hours N supervisor supervisee M N 1 1 N N degree 1 N partial constraint total constraint

Database Basics Jan. 2010Yangjun Chen ACS Instructors: let’s assume this classification includes instructors, professors, part-time people (at least for now). These people have SINs, employee numbers, names, addresses, offices, phones,... instructor SIN office address employee no name phonedegree

Database Basics Jan. 2010Yangjun Chen ACS 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, complex, multivalued? Is this a weak entity or a strong entity? Should department be an attribute? degree

Database Basics Jan. 2010Yangjun Chen ACS Departments: obviously instructors are employed by the University and associated with a department A department has a name, number, office, chair,... department Dnumber chair phone name office

Database Basics Jan. 2010Yangjun Chen ACS 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, complex, multivalued?

Database Basics Jan. 2010Yangjun Chen ACS department Employs relationship: If we assume the relationship between department and instructor is 1:N then we only associate each department with a single instructor, but 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 Both entities are considered strong entities

Database Basics Jan. 2010Yangjun Chen ACS Consider some instances department employs instructor d1 d2 d3 e1 e2 e3 e4 e5 e6 e7

Database Basics Jan. 2010Yangjun Chen ACS department Chair relationship: A department has a chair who has special responsibilities. One person (instructor) is designated as such. instructor chair 11 1:1 is the cardinality of the relationship the relationship is of degree 2; it is a binary relationship.

Database Basics Jan. 2010Yangjun Chen ACS Weak entity types a weak entity does not have a key of its own - may have a partial key the identifying relationship will have total participation for the weak entity e.g. consider courses and sections at UWinnipeg

Database Basics Jan. 2010Yangjun Chen ACS Consider courses and course sections In the fall and winter we have: /3-001 F Intro Computers staff MW 16:30-17:45 3C /3-002 W Intro Computers staff MW 16:30-17:45 3C /3-050 F Intro Computers staff T 18:00-21:00 3C /3-051 W Intro Computers staff T 18:00-21:00 3C13.. Section numbers are 001, 002, 050, 051, … Sections have a section number, a term, days and times, …

Database Basics Jan. 2010Yangjun Chen ACS Consider courses and course sections course 1N Offered-in Section no term meeting Section is a weak entity - it has a discriminator (partial key), section number. Section totally participates in the offered in relationship PK (primary key) of Section is … (offered_in is an identifying relationship) Is meeting multivalued? course no name credit hours description section

Database Basics Jan. 2010Yangjun Chen ACS Data analysis: instructorcourse textbook uses teaches m m n n Note that teaches and uses are both binary relationships: we expect situations where a specific Instructor teaches a specific Course, and where a specific Course uses a specific text

Database Basics Jan. 2010Yangjun Chen ACS Consider instances instructorcoursetextbook

Database Basics Jan. 2010Yangjun Chen ACS Jones and Smith are Instructors instructor course Courses offered are Intro to X, Intro to Y, Z, Advanced X, Advanced Y jones smith Intro to X Z Intro to Y Advanced X Advanced Y

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Consider instances of Instructor teaches Course

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y There is a relationship between Instructor Jones and Course Intro to X

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y This line connects the three dots

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y Smith teaches Advanced Y

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse Jones teaches Intro to X jones smith Intro to X Z Intro to Y Advanced X Advanced Y Jones teaches Advanced X Smith teaches Intro to Y Smith teaches Advanced Y Smith and Jones teach Z together There are two relationships: one between Jones and Z; the other between Smith and Z

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Now let us examine Course uses Textbook Suppose we have two textbooks: The mythical man-month, and UML distilled

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Intro to Y uses The mythical man-month

Database Basics Jan. 2010Yangjun Chen ACS instructor teachescourse usestextbook jones smith Intro to X Z Intro to Y Advanced X Advanced Y UML distilled The mythical man-month Z uses both texts

Database Basics Jan. 2010Yangjun Chen ACS ER-to-Relational mapping 1. Create a relation for each strong entity type For each atomic attribute associated with the entity type, an attribute in the relation will be created. Composite attributes are not included. However the atomic attributes comprising the composite attribute must appear in the pertinent relation. 2. Create a relation for each weak entity type include primary key of owner (an FK - foreign key) owner’s PK + partial key becomes PK 3. For each binary 1:1 relationship choose an entity and include the other’s PK in it as an FK. Include any attributes of the relationship

Database Basics Jan. 2010Yangjun Chen ACS For each binary 1:n relationship, choose the n-side entity and include an FK with respect to the other entity. Include any attributes of the relationship 5.For each binary M:N relationship, create a relation for the relationship include PKs of both participating entities and any attributes of the relationship PK is the concatenation of the participating entity PKs 6.For each multivalued attribute create a new relation include the PK attributes of the entity type PK is the PK of the entity type and the multivalued attribute

Database Basics Jan. 2010Yangjun Chen ACS For each n-ary relationship, create a relation for the relationship include PKs of all participating entities and any attributes of the relationship PK is the concatenation of the participating entity PKs

Database Basics Jan. 2010Yangjun Chen ACS fname, minit, lname, ssn, bdate, address, sex, salary, superssn, dno Dname, dnumber, mgrssn, mgrstartdate Dnumber, dlocation Pname, pnumber, plocation, dnum Essn, pno, hours Essn, dependentname, sex, bdate, relationship EMPLOYEE DEPARTMENT DEPT _LOCATIONS WORKS_ON PROJECT DEPENDENT

Database Basics Jan. 2010Yangjun Chen ACS student graduate undergraduate Specialization and Generalization Specialization is the process of defining a set of sub-entities of some entity type. Generalization is the opposite approach/process of determining a supertype based on certain entities having common characteristics. e.g. employees may be paid by the hour or a salary (part vs full-time) e.g. students may be part-time or full-time; graduate or undergraduate these are similar to 1:1 relationships, but they always involve entities of one (super)type these are ‘is-a’ relationships d

Database Basics Jan. 2010Yangjun Chen ACS student graduate undergraduate d The arc implies graduate and undergraduate are subtypes of student The bubble and the d imply disjoint subtypes (o - overlap subtypes) A student must be a graduate or undergraduate Participation of supertype may be mandatory or optional Subtypes may be disjoint or overlapping a predicate (on an attribute) determines the subtype: e.g. attribute Student_class Student_class = ‘graduate’; Student_class = ‘undergraduate’ Student_class Subtype is determined by the student_class attribute

Database Basics Jan. 2010Yangjun Chen ACS Mapping to a relational database 4 choices: 1. Create separate relations for the supertype and each of the subtypes. 2. Create relations for the subtypes only - each contains attributes from the supertype. 3. (disjoint subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one discriminator attribute. 4. (overlapping subtypes) Create only one relation - includes all of the attributes for the supertype and all for the subtypes, and one logical discriminator attribute per subtype. PK is always the same - determined from the supertype

Database Basics Jan. 2010Yangjun Chen ACS SECRETARYENGINEER d Example for super- & sub-types: choice 1 TECHNICIAN name lname minit fname Ssn bDates Address JobType TypingSpeed TGrade EngType fname, minit, lname, ssn, bdate, address, JobType EMPLOYEE Essn, TypingSpeed SECRETARY Essn, TGrade TECHNICIAN Essn, EngType ENGINEER EMPLOYEE

Database Basics Jan. 2010Yangjun Chen ACS CARTRUCK d Example for super- & sub-types: choice 2 VehicleId PriceLicensePlate TNoOfPassengers NoOfAxles VehicleId, LicensePlate, Price, MaxSpeed, NoOfPassenger CAR VehicleId, LicensePlate, Price, NoOfAxles, Tonnage TRUCK MaxSpeed Tonnage Vehicle

Database Basics Jan. 2010Yangjun Chen ACS SECRETARYENGINEER d Example for super- & sub-types: choice 3 TECHNICIAN name lname minit fname Ssn bDates Address JobType TypingSpeed TGrade EngType fname, minit, lname, ssn, bdate, address, JobType, TypingSpeed, Tgrade, EngType EMPLOYEE

Database Basics Jan. 2010Yangjun Chen ACS Part Manufacture_PartPurchased_Part o Example for super- & sub-types: choice 4 PartNo Description manufactureDate Supplier PartNo, Desription, MFlag, Drawing, ManufactureDate, BatchNo, Pflag, Supplier, ListPrice Part BatchNo DrawingNo ListPrice