Module Title? DBMS E-R Model to Relational Model.

Slides:



Advertisements
Similar presentations
The Relational Model Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Advertisements

Relational Database Design UNIT II 1. 2 Advantages of Using Database Systems Centralized control of a firm’s data Redundancy can be reduced (avoid keeping.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Chapter 3 : Relational Model
BUSINESS DRIVEN TECHNOLOGY Plug-In T4 Designing Database Applications.
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
The Relational Database Model
Monash University Week 7 Data Modelling Relational Database Theory IMS1907 Database Systems.
ETEC 100 Information Technology
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Database Architecture The Relational Database Model.
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
The Relational Database Model
3 The Relational Model MIS 304 Winter Class Objectives That the relational database model takes a logical view of data That the relational model’s.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
44220: Database Design & Implementation Logical Data Modelling Ian Perry Room: C48 Tel Ext.: 7287
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
Concepts and Terminology Introduction to Database.
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
CG084&085 / / 1 The Relational Data Model Properties of Relations Keys and Constraints.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
Instructor: Churee Techawut Basic Concepts of Relational Database Chapter 5 CS (204)321 Database System I.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, Modified by Dr. Mathis 3-1 David M. Kroenke’s Chapter Three: The Relational.
Copyright 2008 McGraw-Hill Ryerson 1 TECHNOLOGY PLUG-IN T5 DESIGNING DATABASE APPLICATIONS.
1 The Relational Database Model. 2 Learning Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
Relational Database. Database Management System (DBMS)
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
Relational Database: RDB Concepts
IE 423 – Design of Decision Support Systems Data modeling and database development.
1 Database & DBMS The data that goes into transaction processing systems (TPS), also goes to a database to be stored and processed later by decision support.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
CSE314 Database Systems Lecture 3 The Relational Data Model and Relational Database Constraints Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Lection №4 Development of the Relational Databases.
1 ER Modeling BUAD/American University Mapping ER modeling to Relationships.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
Logical Database Design and the Relational Model.
Database Systems Logical Data Modelling Tutor:Ian Perry Tel: Web:
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
Logical Database Design and Relation Data Model Muhammad Nasir
Logical Database Design and Relational Data Model Muhammad Nasir
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Standards and Conventions
Logical Database Design and the Rational Model
RELATION.
MIS 322 – Enterprise Business Process Analysis
Data Models.
Translation of ER-diagram into Relational Schema
Data Modelling Introduction
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Design tools and techniques for a relational database system
INSTRUCTOR: MRS T.G. ZHOU
Presentation transcript:

Module Title? DBMS E-R Model to Relational Model

Module Title? DBMS WHY  Relational model was first proposed in 1970 by Dr E F (Ted) Codd.  Purpose:  Achieve program/data independence  The structure of the database is stored separately in the system catalog from the access of the application programs.  Treat data in a disciplined way (data is ordered rows and column)  Apply rigor of mathematics (sum: total marks)  manipulating a set of records at a time  Use of set theory Improve programmer productivity (join, union, cross product)

Module Title? DBMS What is a Relational Database?  A relational database is made up of tables (relations) in which data are stored.  A table (relation) is a 2-dimensional structure made up of columns (attributes) and rows (tuples).

Module Title? DBMS table 1. A relation is a table of values row The "ENum" column column relation tuple Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003 TABLE **

Module Title? DBMS FORMAL DEFINITIONS  Each row in the EMPLOYEE table may be referred to as a tuple in the table and would consist of four values, e.g.:.  A relation (table) may be regarded as a set of tuples (rows). Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003

Module Title? DBMS table 2. No two rows in a table can be the same (i.e., they can't have identical values) relation tuple Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003 The ROWS of a TABLE row

Module Title? DBMS  The columns of a table are also called attributes of the relation.  The attribute help in interpreting the meaning of the values  The attribute names will be useful in searching the table. For example: Find all EName where Dept=E21. Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003 The COLUMNS of a TABLE In plain English, that would be ________________________ Attributes

Module Title? DBMS  A domain is a set of values. The COLUMNS of a TABLE Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/ Domains Attributes p. 127

Module Title? DBMS  A domain is a set of values. The COLUMNS of a TABLE Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003 A domain for Enum is all positive integers greater than 0 and less than A domain for EName is all stings less than 26 characters. Example domains Domains are established in accordance with business rules.

Module Title? DBMS  A domain has a name, data type, and a format.  It also has constraints and a set of permissible operators The COLUMNS of a TABLE Employee ENum EName Dept Hire_date 204 R. B. Jones E21 11/01/ M. R. Brent E21 10/10/2003 Consider the Hire_date column of the Employee table: The domain name is denoted dom(Hire_date) and is the set of all valid hire dates. The domain data type is, say, character string The domain format is mm/dd/yyyy

Module Title? DBMS Relational Database Terminology  Record or Tuple: Each row in the relation.  Attribute: Each column in the relation.  Domain: The set of allowable values for a column.  Degree: The number of columns in a relation.  Cardinality: The number of rows in a relation.

Module Title? DBMS Schema Relation schema = relation name + attributes, in order (+ types of attributes). E.g. Student( rollno, stname,gsm,addr) Database = collection of relations. Database schema = set of all relation schemas in the database.

Module Title? DBMS Properties of Relations  There are no duplicate tuples.  This property follows from the fact that the body of the relation is a mathematical set (i.e., a set of tuples), and sets in mathematics by definition do not include duplicate elements.  If a "relation" contains duplicate tuples, then it is not a relation.

Module Title? DBMS  Tuples are unordered (top to bottom).  Sets in mathematics are not ordered. So, even if a relation A's tuples are reversely ordered, it is still the same relation.  Thus, there is no such thing as "the 5th tuple" or the last tuple. In other words, there is no concept of positional addressing.

Module Title? DBMS  Attributes are unordered (left to right).  This property follows from the fact that the heading of a relation is also defined as a set.  There is no such thing as "5th attribute" or the last attribute.

Module Title? DBMS  All attribute values are atomic.  At every row-and-column position within the table, there always exists precisely one value, never a list of values.  Or equivalently, relations do not contain repeating groups.  A relation satisfying this condition is said to be in First Normal Form.

Module Title? DBMS Rules to convert E-R to Relational model:  An entity type turns into a relation table:  Give it a sensible name – avoid reserved words and no spaces in attribute names.  Choose appropriate Names, which are self-explanatory.  Each attribute turns into a column/field in the relation:  Keep the attribute domains – you will need them later when you implement the schema in Oracle.  The primary key of the entity is the primary key of the table:  It can be composite if required. It can never be null.

Module Title? DBMS Transforming Entity Sets and Their Attributes EMPLOYEE EMPID[PK] NAME SALARY

Module Title? DBMS The above ER Model is translated into the following relational design: EMPLOYEE (empid, name, salary)

Module Title? DBMS Transforming 1:1 Relationships 1:1 EMPLOYEE AUTO

Module Title? DBMS Transforming 1:1 Relationships EMPLOYEE( EmpNum, Name, Phone,...) AUTO( AutoId, Model, Year, Color,..., EmpNum) or EMPLOYEE( EmpNum, Name, Phone,..., AutoID) AUTO( AutoID, Model, Year, Color,...)  In both cases, we would want to enforce referential integrity by requiring that the value of a foreign key in one relation/table appear as the value of a primary key in the other relation/table.

Module Title? DBMS Transforming One to Many Relationships 1:N TEACHER STUDENT

Module Title? DBMS Transforming One to Many Relationships TEACHER( TeacherName, Phone_no, Dept) STUDENT( StudentId, StuName,..., TeacherName)  Transformation Rule: The primary key of the entity set on the "One" side of the relationship becomes a foreign key of the entity set on the "Many" side of the relationship.

Module Title? DBMS Transforming Many to Many E-R Relationships M:N STUDENT CLASS

Module Title? DBMS Transforming Many to Many E-R Relationships STUDENT( StudentNum, StuName, Phone,...) CLASS( ClassNum, ClassName,...) STU-CLASS( StudentNum, ClassNum)  RULE: Create a new relation, called an Intersection relation, whose only (unless there is also an attribute belonging to the relationship) attributes will be a composite primary key consisting of the primary keys of the entity set participants in the relationship.

Module Title? DBMS Keys in DBMS  A simple key contains a single attribute.  A composite key is a key that contains more than one attribute.  A candidate key is an attribute (or set of attributes) that uniquely identifies a row.  A candidate key must possess the following properties:  Unique identification - For every row the value of the key must uniquely identify that row.  Non redundancy - No attribute in the key can be discarded without destroying the property of unique identification.

Module Title? DBMS Keys in DBMS  A primary key is the candidate key which is selected as the principal unique identifier.  Every relation must contain a primary key. The primary key is usually the key selected to identify a row when the database is physically implemented.  For example, a part number is selected instead of a part description.

Module Title? DBMS Keys in DBMS  A super key is any set of attributes that uniquely identifies a row. A super key differs from a candidate key in that it does not require the non redundancy property.  Imagine a table with the fields,, and.  This table has many possible superkeys. Three of these are, and.  Of those listed, only is a candidate key, as the others contain information not necessary to uniquely identify records.

Module Title? DBMS Keys in DBMS  A foreign key is an attribute (or set of attributes) that appears (usually) as a non key attribute in one relation and as a primary key attribute in another relation. I say usually because it is possible for a foreign key to also be the whole or part of a primary key:  A many-to-many relationship can only be implemented by introducing an intersection or link table which then becomes the child in two one-to-many relationships. The intersection table therefore has a foreign key for each of its parents, and its primary key is a composite of both foreign keys.  A one-to-one relationship requires that the child table has no more than one occurrence for each parent, which can only be enforced by letting the foreign key also serve as the primary key.

Module Title? DBMS DATA INTEGRITY CONSTRAINTS:  A constraint helps us to implement business rules in the database.  Type of constraints:  Not Null: Attribute value is must. E.g. Studentname, address.  Unique: Attribute value should be different or not same. E.g. Rollno.  Primary Key: Attribute which is Unique + Not null. E.g. Rollno.  It is an attribute or set of attributes, which uniquely identifies the record in a relation.  This is also known as the entity integrity rule.

Module Title? DBMS DATA INTEGRITY CONSTRAINTS:  Foreign Key:The attribute, which is primary in other table.  Whenever we enter value in foreign key attribute it will check with the primary key value.  So, this is also called Referential Integrity.  Check : Data has to follow some condition or rule.  E.g. bank balance amount should not be less than 5 Student marks not greater than 100

Module Title? DBMS Primary Key COURSEIDNAME COMPCOMPUTING BITBUSINESS INFORMATION TECHNOLOGY PBITPART TIME BIT PHBAPART TIME BUSINESS HBABUSINESS HACCACCOUNTING Primary key

Module Title? DBMS Foreign Key- REFRENTIAL INTEGRITY  STUDENT STUDIDSTUDNAMECOURSEID 99222RAMLACOMP 20029REHABHBA 20020RASHIDPHBA 99149ZAHRACOMP 99090AHMEDBIT Primary key Foreign key