The Relational Model 1 Prof. Sin-Min Lee Department of Mathematics and Computer Science Prof. Sin-Min Lee Department of Computer Science.

Slides:



Advertisements
Similar presentations
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
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.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
Relational Model (CB Chapter 4) CPSC 356 Database Ellen Walker Hiram College.
SQL Lecture 10 Inst: Haya Sammaneh. Example Instance of Students Relation  Cardinality = 3, degree = 5, all rows distinct.
CIT 613: Relational Database Development using SQL Introduction to SQL.
Chapter 3 The Relational Model Transparencies © Pearson Education Limited 1995, 2005.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 The Basic (Flat) Relational Model.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
The Relational Model 1 Prof. Sin-Min Lee Department of Mathematics and Computer Science Prof. Sin-Min Lee Department of Computer Science.
The Relational Model Codd (1970): based on set theory Relational model: represents the database as a collection of relations (a table of values --> file)
Database Architecture The Relational Database Model.
Chapter 5 Relational Model Concepts Dr. Bernard Chen Ph.D. University of Central Arkansas.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
CS 380 Introduction to Database Systems (Chapter 5: The Relational Data Model and Relational Database Constraints)
Relational Model & Relational Algebra. 2 Relational Model u Terminology of relational model. u How tables are used to represent data. u Connection between.
Lecture 2 The Relational Model. Objectives Terminology of relational model. How tables are used to represent data. Connection between mathematical relations.
Chapter 4 The Relational Model Pearson Education © 2014.
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Module Title? DBMS E-R Model to Relational Model.
44220: Database Design & Implementation Logical Data Modelling Ian Perry Room: C48 Tel Ext.: 7287
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Fundamentals of Relational Database Yong Choi School of Business CSUB, Bakersfield.
DatabaseIM ISU1 Fundamentals of Database Systems Chapter 5 The Relational Data Model.
Chapter 3 The Relational Model. 2 Chapter 3 - Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
1 The Relational Model By Elena Ciriani CS157A February 19, 2004 Professor Lee.
ICOM 5016 – Introduction to Database Systems Lecture 5b Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
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 Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
Relational Database. Database Management System (DBMS)
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
FEN Introduction to the database field:  The Relational Model Seminar: Introduction to relational databases.
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
12/2/2015CPSC , CPSC , Lecture 41 Relational Model.
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.
The Relational Model. 2 Relational Model Terminology u A relation is a table with columns and rows. –Only applies to logical structure of the database,
CIT 613: Relational Database Development using SQL Introduction to SQL DeSiaMorePowered by DeSiaMore 1.
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Database Systems Logical Data Modelling Tutor:Ian Perry Tel: Web:
CHAPTER 2 : RELATIONAL DATA MODEL Prepared by : nbs.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
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
Week 2 Lecture Database Development Process
Chapter 1: Introduction. 1.2 Database Management System (DBMS) DBMS contains information about a particular enterprise Collection of interrelated data.
Chapter 4 The Relational Model Pearson Education © 2009.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Rationale Databases are an integral part of an organization. Aspiring Database Developers should be able to efficiently design and implement databases.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
Logical Database Design and the Rational Model
Data Models.
Lecture 2 The Relational Model
Translation of ER-diagram into Relational Schema
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Chapter 4 The Relational Model Pearson Education © 2009.
Design tools and techniques for a relational database system
Chapter 4 The Relational Model Pearson Education © 2009.
Presentation transcript:

The Relational Model 1 Prof. Sin-Min Lee Department of Mathematics and Computer Science Prof. Sin-Min Lee Department of Computer Science

History of Relational Model First proposed by a E.F. Codd in Codd proposed the Relational model in  “ A relational model of data for large shared data banks.” He linked the representation of data with that of mathematical sets. First research started at IBM’s San Jose Research Laboratory. Prototype was called System R. Commercial RDBMS’s started to appear in late 1970’s and early 1980’s. Most well known is Oracle.

Dr. Edgar F. Codd ( ) Codd completed his PhD at the University of Michigan in 1963, and presented a thesis on the topic of a self- reproducing computer consisting of a large number of simple identical cells, each of which interacts in a uniform manner with its four immediate neighbors. Codd reported this work in a book entitled Cellular Automata published by Academic Press in Codd completed his PhD at the University of Michigan in 1963, and presented a thesis on the topic of a self- reproducing computer consisting of a large number of simple identical cells, each of which interacts in a uniform manner with its four immediate neighbors. Codd reported this work in a book entitled Cellular Automata published by Academic Press in 1968.Cellular AutomataCellular Automata

Edgar Codd The relational model devised by Codd was explored during the 1970s, and commercial relational database products began to emerge in the 1980s, originally for mainframe systems and later for microcomputers. Edgar Codd first wrote about the concept of relational databases in his paper "A Relational Model of Data for Large Shared Data Banks" in He was using the term "relation" in the strict mathematical sense of a table with a few special properties. Thus Codd was describing a system where all of the database - data, structure, rules - is housed in simple tables of rows and columns. The relational model devised by Codd was explored during the 1970s, and commercial relational database products began to emerge in the 1980s, originally for mainframe systems and later for microcomputers. Edgar Codd first wrote about the concept of relational databases in his paper "A Relational Model of Data for Large Shared Data Banks" in He was using the term "relation" in the strict mathematical sense of a table with a few special properties. Thus Codd was describing a system where all of the database - data, structure, rules - is housed in simple tables of rows and columns.relational modelrelational databases"relation"database relational modelrelational databases"relation"database

Edgar Codd While this may seem obvious to us today, it was by no means obvious in Codd went on to define relational databases more completely where he laid out twelve principles of relational databases in His most recent work in 1990, expands the list to 333 requirements.(Codd 90) Normalization for relational databases was introduced by Dr. E. F. Codd back in 1970 when he wrote his original paper. The concept has since been expounded upon by other experts in the field. While this may seem obvious to us today, it was by no means obvious in Codd went on to define relational databases more completely where he laid out twelve principles of relational databases in His most recent work in 1990, expands the list to 333 requirements.(Codd 90) Normalization for relational databases was introduced by Dr. E. F. Codd back in 1970 when he wrote his original paper. The concept has since been expounded upon by other experts in the field.Codd 90 NormalizationCodd 90 Normalization Read his obituary Read his obituary

Read: news/local/ htm?1c IBM database developer dead at 79 IBM database developer dead at 79 `RELATIONAL' MODEL IS BASIS OF TODAY'S TRANSACTIONS By Lisa M. Krieger Mercury News `RELATIONAL' MODEL IS BASIS OF TODAY'S TRANSACTIONS By Lisa M. Krieger Mercury News Edgar F. Codd, an IBM computer pioneer who created the ``relational database model'' that underlies a $7 billion industry of storing the world's online business data, died of heart failure at home Friday in Williams Island, Fla. He was 79. Edgar F. Codd, an IBM computer pioneer who created the ``relational database model'' that underlies a $7 billion industry of storing the world's online business data, died of heart failure at home Friday in Williams Island, Fla. He was 79. Bank accounts, credit cards, stock trading, travel reservations, online auctions and innumerable other now-routine data transactions all rely on Codd's model, based on highly abstract and complex mathematical theory. Bank accounts, credit cards, stock trading, travel reservations, online auctions and innumerable other now-routine data transactions all rely on Codd's model, based on highly abstract and complex mathematical theory. Before Codd's landmark research paper in 1970, it was possible to store lots of information -- but analyzing it was difficult, requiring lines and lines of code for even simple tasks. Before Codd's landmark research paper in 1970, it was possible to store lots of information -- but analyzing it was difficult, requiring lines and lines of code for even simple tasks.

Codd ’ s Original Paper “ A Relational Model of Data for Large Shared Data Banks ” “ A Relational Model of Data for Large Shared Data Banks ” Communications of the ACM, Volume 13, Number 6, June 1970 Communications of the ACM, Volume 13, Number 6, June 1970 Lower level (basement) of the new Martin Luther King, Jr. Library Lower level (basement) of the new Martin Luther King, Jr. Library Get to roll the shelves apart to access journals. Get to roll the shelves apart to access journals.

Codd ’ s Reasons Data independence from database implementation such as machine representation Data independence from database implementation such as machine representation Natural structure of data Natural structure of data Can be analyzed mathematically (Codd was a mathematician by training) Can be analyzed mathematically (Codd was a mathematician by training)

Alternative: Network Model Charles A. Bachman 1973 ACM Turing Award Lecture “ The Programmer as Navigator ” Charles A. Bachman 1973 ACM Turing Award Lecture “ The Programmer as Navigator ” Communications of the ACM, Volume 16, Number 11, November 1973, pp Communications of the ACM, Volume 16, Number 11, November 1973, pp

INTRODUCTION The relational model is the most used data model for commercial data-processing because it is simple to use and to maintain. A relational data model is based on a collection of tables. The user of the database system may query these tables, insert new tuples, and update (modify) tuples. There are several languages for expressing these operations.

Data Models · Codd suggests that any data model has three components: the data structures; the data structures; the integrity constraints; the integrity constraints; the data manipulation operators. the data manipulation operators.

Relational Data Structure EMPLOYEE Emp# Name Emp Sex Mgr Emp# E1 JonesMaleE65 E6 SmithMaleE28 E28Jones Female- Relation Attribute Heading Body Female Male Gender Domain

Basic Structure account-numberbranch-namebalance A-101Downtown500 A-102Perryridge400 A-201Brighton900 A-215Mianus700 The account table below represents a relation in the relational model. The three columns titles are the attributes and their domains. Each row is called a tuple. An account is a subset of the set of all possible tuples.

The Domain Emp# E1 E2 E3 Name Red Brown Black Mgr# - E1 E1, E2, E3,E4 Red, Brown Black, Blue Attributes Domains Employee Person Name Emp#

Seven Characteristics of a relation The name of the relation is different from all others. Each cell of the relation contains only one value Each attribute (or field) has a name that is distinct. All the values of a particular attribute are from the same domain. The order of the attributes makes no difference. There are no duplicate tuples The order of the tuples makes no difference.

Example of the Student table. Primary Key

Other terms... Cardinality = Number of rows Cardinality = Number of rows Degree = Number of columns Degree = Number of columns Cardinality = 6 Degree = 5

Database Schema Database Schema is the logical design of the database Database Schema is the logical design of the database Database instance is a snapshot of the data in the DB at a given instance in time Database instance is a snapshot of the data in the DB at a given instance in time Relation instance is the programming language notion of a value of a variable Relation instance is the programming language notion of a value of a variable

Database Schema Relation schema consists of a list of attributes and their corresponding domain. As a convention, uppercase letter are used so Account-schema=(account-number, branch- name, balance) This means that account is a relation on Account-schema by account(Account-schema)

Database Schema Relation instance is the set of values of a relation at a specific moment in time. This values may change in time causing a change in the relation as it is updated.

The Relational Data Model · DATA STRUCTURES - domain, attribute, relation, tuple, primary key, degree, cardinality. INTEGRITY CONSTRAINTS - entity integrity and referential integrity. INTEGRITY CONSTRAINTS - entity integrity and referential integrity. DATA MANIPULATION OPERATIONS - defined through relational algebra and equivalent relational calculus. DATA MANIPULATION OPERATIONS - defined through relational algebra and equivalent relational calculus.

Keys Superkey is a set of one or more attributes that allow us to identify uniquely an entity in the entity set. Superkey is a set of one or more attributes that allow us to identify uniquely an entity in the entity set. Candidate Key are minimal superkey in an entity, one of those keys is selected to be the primary key Candidate Key are minimal superkey in an entity, one of those keys is selected to be the primary key Primary Key is a candidate key that is chosen to identify entities within an entity set Primary Key is a candidate key that is chosen to identify entities within an entity set Foreign Key is a primary key of another relation schema Foreign Key is a primary key of another relation schema

Keys If K of R is a superkey for R, then the relation r(R) does not have two tuples with the same value. So if t1 and t 2 are in r t 1 = t 2

Find Candidate Keys R(A, B, C, D) R(A, B, C, D) {A, B} {A, C} {A, D} {B, C} {B, D} {C, D} X {A,C,D} {B, C, D}  XX  X  = okay  = not okay

How to determine keys Strong entity set: the entity primary key becomes the relation primary key Strong entity set: the entity primary key becomes the relation primary key Weak entity set: the primary key of the relation is the union of the strong entity set primary key and the discriminator Weak entity set: the primary key of the relation is the union of the strong entity set primary key and the discriminator Relation set: the union of the primary keys of the related entity sets becomes a superkey of the relation Relation set: the union of the primary keys of the related entity sets becomes a superkey of the relation

How to determine keys Combined tables: in a many-to-one, the primary key of the many becomes the relation primary key. In a one-to-one either primary key can be used Combined tables: in a many-to-one, the primary key of the many becomes the relation primary key. In a one-to-one either primary key can be used Multivalued attributes: the entity primary key becomes the primary key Multivalued attributes: the entity primary key becomes the primary key

account-number branch-name balance Schema Diagram branch-name branch-city assets customer-name loan-number customer-name customer-street customer-city customer-name account-number loan-number branch-name amount account depositorcustomer branchloan borrower dependency relation shade indicates primary key A database schema with primary and foreign key dependencies primary

Entity Integrity · No component of the Primary Key of a base relation is allowed to accept nulls. Surname Red Black Red Black Given Name John Fred Salary $40,000 $50,000 $60,000 $70,000

Foreign Key · A foreign key is an attribute or attribute combination of one relation R2 whose values are required to match those of the primary key of relation R1 where R1 and R2 are not necessarily distinct. Note that a foreign key and the corresponding primary key should be defined on the same domain(s). Emp# e1 e2 e3 ename red blue brown Dept d1 d2 d3 Worksfordept d1 d2 Dname Pay Tax Art Employee Dept Foreign key

Referential Integrity If base relation R2 includes a foreign key FK matching the primary key PK of some base relation R1 then every value of FK in R2 must either (a) be equal to the value of PK in some tuple of R1, or (b) be wholly null. Note that PK and FK may comprise more than one attribute and that R1 and R2 are not necessarily distinct. ( Stated more simply a foreign key should be a valid primary key value or null.)

Foreign Key Rules For each foreign key three rules need to be answered: Can the foreign key accept nulls ? What should happen on an attempt to delete the target of a foreign key reference? What should happen on an attempt to update the target of a foreign key reference ? Emp# e1 e2 e3 ename red blue brown Dept d1 d2 d3 Worksfordept d1 d2 Dname Pay Tax Art EmployeeDept

Foreign Key Rules When should foreign key rules be checked ? Dept (Dept#, Dname, Budget) Emp (Emp#, Ename, Salary, WorksforDept#) WorksforDept# References Dept delete cascades, update cascades WorksforDept# References Dept delete cascades, update cascades Depend (Emp#, Dependname, Date-of-birth) Emp# references Emp delete cascades, update cascades Emp# references Emp delete cascades, update cascades

Example of the Class table. Primary Key

Foreign key example

Relational instances in the Student relation The content of the table (a grouping of rows) are called relational instances The content of the table (a grouping of rows) are called relational instances These instances are unordered, and no two rows can be exactly alike These instances are unordered, and no two rows can be exactly alike A relational instance

Integrity Constraints All DBMS ’ must have some form of ICs to prevent invalid data from being entered. All DBMS ’ must have some form of ICs to prevent invalid data from being entered. Domain constraints specify the set of values which may be used for each field. Domain constraints specify the set of values which may be used for each field. Other constraints, such as key or tuple, may limit which values from the domain can be used for a given field in a given instance. Other constraints, such as key or tuple, may limit which values from the domain can be used for a given field in a given instance. Key constraints require that each set of fields in the key be unique for each entry. Key constraints require that each set of fields in the key be unique for each entry.

Enforcing Integrity Constraints Each DBMS should have means to resolve invlaid entries such as: Each DBMS should have means to resolve invlaid entries such as: What happens if an entry that duplicates a key entry is entered? What happens if an entry that duplicates a key entry is entered? What should be done if an entry of a foreign key is deleted? What should be done if an entry of a foreign key is deleted? A foreign key is a key where at least one field depends on a field from a different table. A foreign key is a key where at least one field depends on a field from a different table. What happens when an invalid entry is entered? What happens when an invalid entry is entered?

Relation schema Associated with each attribute is a set of values, called a domain, that can be assigned to the entry of a tuple corresponding to the attribute. Associated with each attribute is a set of values, called a domain, that can be assigned to the entry of a tuple corresponding to the attribute. A relation schema is a set of attributes. A relation schema is a set of attributes. Example EMP = { Name, SSN, DeptName, Salary, Birthdate } Example EMP = { Name, SSN, DeptName, Salary, Birthdate } Convention EMP(Name,SSN,DeptName,Salary,Birthdate) Convention EMP(Name,SSN,DeptName,Salary,Birthdate)

IBM Relational Products DB2 MVS/370 MVS/XA SQL/DS VM/CMS DOS/VSE QMF front-end to DB2 and SQL/DS CSP application development tool Numerous other RDBMS ORACLE (SQL*Forms) INGRES from ASK Corp. (OSL,ABF) AIM/RDB from Fujitsu INFORMIX VAXSQL/Rdb from DEC NonStop SQL from Tandem Relational DBMS Products Microcomputer versions ORACLE INGRES dBase IV microSQL practically all micro DBMS

The relational model is based on set operations. Tables are sets of rows. The actual storage structure is hidden from the user. The relational model is just concerned with a logical view of the data, not the physical view. There are no pointers for the user to worry about. The only data are explicit values in tables. All data values in the cells of tables are Atomic (also known as Scalar). Exactly one data value and not a set or a repeating group is allowed in each cell. Relational databases are the most widely used in the world ( 90+%.) A mathematical viewpoint helped to shape a database industry. Future? Possibly Object Oriented Database model.

Query Languages Users use query languages to request information from the database SQL is the most spread. Database uses two types of query languages: Procedural language: the user instructs the system to perform a sequence of operations on the database Nonprocedural language: the user describes the desired information without giving a specific procedure for obtain the information