ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 5 – September 4 th,

Slides:



Advertisements
Similar presentations
IS698: Database Management Min Song IS NJIT. The Relational Data Model.
Advertisements

Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
Relational Algebra Jianlin Feng School of Software SUN YAT-SEN UNIVERSITY courtesy of Joe Hellerstein for some slides.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 8 – File Structures.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 The Relational Model Chapter 3.
1 CHAPTER 4 RELATIONAL ALGEBRA AND CALCULUS. 2 Introduction - We discuss here two mathematical formalisms which can be used as the basis for stating and.
D ATABASE S YSTEMS I R ELATIONAL A LGEBRA. 22 R ELATIONAL Q UERY L ANGUAGES Query languages (QL): Allow manipulation and retrieval of data from a database.
The Relational Model. Introduction Introduced by Ted Codd at IBM Research in 1970 The relational model represents data in the form of table. Main concept.
Relational Algebra Ch. 7.4 – 7.6 John Ortiz. Lecture 4Relational Algebra2 Relational Query Languages  Query languages: allow manipulation and retrieval.
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A Modified by Donghui Zhang.
1 Lecture 11: Basic SQL, Integrity constraints
The Relational Model Class 2 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) (From ER to Relational)
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 28 Database Systems I The Relational Data Model.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
1 Relational Model. 2 Relational Database: Definitions  Relational database: a set of relations  Relation: made up of 2 parts: – Instance : a table,
The Relational Model Lecture 3 Book Chapter 3 Relational Data Model Relational Query Language (DDL + DML) Integrity Constraints (IC) From ER to Relational.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
By relieving the brain of all unnecessary work, a good notation sets it free to concentrate on more advanced problems, and, in effect, increases the mental.
Relational Algebra.
44220: Database Design & Implementation Logical Data Modelling Ian Perry Room: C48 Tel Ext.: 7287
Content Resource- Elamsari and Navathe, Fundamentals of Database Management systems.
Relational Data Model, R. Ramakrishnan and J. Gehrke with Dr. Eick’s additions 1 The Relational Model Chapter 3.
The Relational Model. Review Why use a DBMS? OS provides RAM and disk.
10/9/20151 The Relational Data Model TCU Database Systems Last update: September 2004 Reference: Elmasri 4 th edition, chapter 5.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Lecture 05 Structured Query Language. 2 Father of Relational Model Edgar F. Codd ( ) PhD from U. of Michigan, Ann Arbor Received Turing Award.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model.
MIS 3053 Database Design & Applications The University of Tulsa Professor: Akhilesh Bajaj RM/SQL Lecture 1 ©Akhilesh Bajaj, 2000, 2002, 2003, All.
ICOM 5016 – Introduction to Database Systems Lecture 5b Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
1 The Relational Model. 2 Why Study the Relational Model? v Most widely used model. – Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. v “Legacy.
FALL 2004CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Relational Data Model Ch. 7.1 – 7.3 John Ortiz Lecture 3Relational Data Model2 Why Study Relational Model?  Most widely used model.  Vendors: IBM,
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
1 Relational Algebra and Calculas Chapter 4, Part A.
1.1 CAS CS 460/660 Introduction to Database Systems Relational Algebra.
ICS 321 Fall 2011 The Relational Model of Data (i) Asst. Prof. Lipyeow Lim Information & Computer Science Department University of Hawaii at Manoa 8/29/20111Lipyeow.
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Database Management Systems Chapter 4 Relational Algebra.
Chapter 2 Introduction to Relational Model. Example of a Relation attributes (or columns) tuples (or rows) Introduction to Relational Model 2.
Chapter 2: Intro to Relational Model. 2.2 Example of a Relation attributes (or columns) tuples (or rows)
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.
Database Management Systems, R. Ramakrishnan1 Relational Algebra Module 3, Lecture 1.
CMPT 258 Database Systems Relational Algebra (Chapter 4)
CS34311 The Relational Model. cs34312 Why Relational Model? Currently the most widely used Vendors: Oracle, Microsoft, IBM Older models still used IBM’s.
Jennifer Widom Relational Databases The Relational Model.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez-Martínez Electrical and Computer Engineering Department Lecture 10 – September 18,
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
Chapter 3 The Relational Model. Why Study the Relational Model? Most widely used model. Vendors: IBM, Informix, Microsoft, Oracle, Sybase, etc. “Legacy.
1 CS122A: Introduction to Data Management Lecture #4 (E-R  Relational Translation) Instructor: Chen Li.
CENG 351 File Structures and Data Management1 Relational Model Chapter 3.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Module 2: Intro to Relational Model
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Relational Databases The Relational Model.
Relational Databases The Relational Model.
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Presentation transcript:

ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 5 – September 4 th, 2001

ICOM 6005Dr. Manuel Rodriguez Martinez2 Readings Read –Chapter ? of old version of textbook –Chapter 4 of new version of texbook –Paper by E.F. Codd A Relational Model of Data for Large Shared Data Banks Get: –ICOM6005-Manual #2 – from Engineering Reproduction Center

ICOM 6005Dr. Manuel Rodriguez Martinez3 Some clarifications: Relational Model Relation model –Conceptual model for data –Data is modeled in tabular fashion Rows is a record containing related information that describes an entity. Columns are attributes of the entity (also called fields) Row represents a group of related attributes that represent or give some information about the entity. –Relation schema – describes the characteristics of the relation Relation name List of attributes –Attribute name –Attribute domain Domain –Name –Associated values

ICOM 6005Dr. Manuel Rodriguez Martinez4 Attribute Domain The domain is the set of possible values that an attribute can assume. –Z – set of integers –A – set of dates after January 1 st, –M – set of ages greater or equal than 18 years. In relational model, the domain is described by a domain name and data type. –Domain is equivalent to a data type in a programming language Both describe legal values for a variable Can be user-defined –Ex: M – set of ages greater or equal than 18 years.

ICOM 6005Dr. Manuel Rodriguez Martinez5 Example: University Students Relation Schema: Students(sid:string, name:string,login:string, age:integer,gpa:integer); Relation name: Students Attributes: sid, name, login, age, gpa Domains: string, integer

ICOM 6005Dr. Manuel Rodriguez Martinez6 Relation instance Relation instance – set of rows (also called tuples) that follow a relation schema R. –called relation for short. Technically, a relation should not have duplicates, but most commercial database management systems allow them. Example: Students(sid:string, name:string,login:string, age:integer,gpa:integer); sidnameloginagegpa

ICOM 6005Dr. Manuel Rodriguez Martinez7 Relation instance Order of the rows is irrelevant If the attributes in the schema are named, then the order is irrelevant – in theory –Most commercial systems assign a position to the fields –Example: Students(sid:string, name:string,login:string, age:integer,gpa:integer); sid – column 1 name – column 2 login – column 3 age – column 4 gpa – column 5 –You can access attributes (fields) by either name or position

ICOM 6005Dr. Manuel Rodriguez Martinez8 Relational schema notation Given a set of Domain D1, D2, …, Dn a relation R over these domains is a subset of D1xD2x…Dn. R is specified as: –R = {a1:D2,a2:D2,…,an:Dn| where a1  D1, a2  D2, …, an  Dn. –Sometimes, a relation R is described simply by schema as R(a1:D2, a2:D2,…,an:Dn) –Lists the attribute names and their corresponding domain –If each domain is well-known or understood from the context of a document, then the relation is simply describe by the attribute names R(a1, a2, …, an) –Merely indicates the attribute names in the

ICOM 6005Dr. Manuel Rodriguez Martinez9 Keys Candidate keys – a set of attributes that uniquely identifies a tuple r in a relation R. –Just call it a key. –Two tuples cannot have the same key –In commercial DBMS this must be enforced by a constrain Remember that commercial systems allow duplicate tuples A constrain is a restriction on the values of one or more attributes. –If an attribute is remove from a candidate key, it is no longer a key. Super keys – set of attributes that contain a subset of attributes which is a candidate key Primary keys – candidate key selected by a database designer to be the key of a relation R.

ICOM 6005Dr. Manuel Rodriguez Martinez10 Examples on keys Candidate keys – {sid}, {login,age} Super Keys – {sig, name}, {sid, gpa}, {sid, login, age} Primary key – {sid} Non-keys – {login}, {age}, {name, login} sidnameloginagegpa

ICOM 6005Dr. Manuel Rodriguez Martinez11 Some issues on keys Every relation has a candidate keys – in theory –Relational DBMS might allow relation with no keys A relation R might have multiple candidate keys –Example: Students can have either {sid} or {login,age} Primary key is chosen by DB designer. Usually is the candidate key that makes the most sense, meaning that is –Simple – as few attributes as possible. Student ID – sid -> just one attribute –Intuitive – attributes naturally identify a tuple. Student ID – sid -> natural way to identify a student

ICOM 6005Dr. Manuel Rodriguez Martinez12 Relational Algebra Query language – specialized language to ask questions to the database. –These are normally called “queries” Relational algebra expresses queries as operations to be executed on the data (input relation). –Procedural expressions in the sense that they specify operation to be applied to an input relation –The do not specify how to implement these expressions, so they are not a procedural language. Relational algebra expression are specified over the schema of a relation, but are applied to an instance. –Relation names and attributes appear in the expressions.

ICOM 6005Dr. Manuel Rodriguez Martinez13 Relational Algebra (cont.) In a relational algebra expression: –Input – is a relation R which can either be: A base relation that exists as an instance in the database. A temporary relation that is the result of another relational algebra expression. –Composition of relational algebra expressions –Output – a new relation R different from the base relations that are stored in the database (different from the existing instances). Relational algebra expressions can be the input to other expression. A relation is always the output of any relational algebra expression.

ICOM 6005Dr. Manuel Rodriguez Martinez14 University Database Schema Students(sid:string, name:string,login:string, age:integer,gpa:integer); Courses(cid:string, section:integer, name:string, room:integer); Registration(cid:string, section:integer, sid:string); Key fields are underlined.

ICOM 6005Dr. Manuel Rodriguez Martinez15 Relational Instance: Students sidnameloginagegpa Information about enrolled students

ICOM 6005Dr. Manuel Rodriguez Martinez16 Relational Instance: Courses cidsectionnameroom 80101English I English I English I Databases Databases Electronics Calculus276 Information about courses being offered

ICOM 6005Dr. Manuel Rodriguez Martinez17 Relational Instance: Registration cidsectionsid Information about student enrollment

ICOM 6005Dr. Manuel Rodriguez Martinez18 Selection Operation Extracts a set of tuples from a relation R based on a boolean condition c. –Results is a set new relation with the same schema as input relation R. –Selection condition c is a predicate that restricts the tuples that are in the result. Tuples must “pass” the condition to be in the selection result. Formalism: Given a relation R, the selection operation: is the defined as S = { t | t  R and c(t) = true}

ICOM 6005Dr. Manuel Rodriguez Martinez19 Selection Example 1 Get all students with a gpa greater than Relation Algebra Expression: Result: sidnameloginagegpa

ICOM 6005Dr. Manuel Rodriguez Martinez20 Selection Example 2 Get the course information for English I Relational Algebra Expression: Result: cidsectionnameroom 80101English I English I English I333