ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – 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

Chapter 3 : Relational Model
More Set Definitions and Proofs 1.6, 1.7. Ordered n-tuple The ordered n-tuple (a1,a2,…an) is the ordered collection that has a1 as its first element,
2.1 Sets. DEFINITION 1 A set is an unordered collection of objects. DEFINITION 2 The objects in a set are called the elements, or members, of the set.
Sets Definition of a Set: NAME = {list of elements or description of elements} i.e. B = {1,2,3} or C = {x  Z + | -4 < x < 4} Axiom of Extension: A set.
Chapter 3. 2 Chapter 3 - Objectives Terminology of relational model. Terminology of relational model. How tables are used to represent data. How tables.
Chapter 3: Relational Model
1 Minggu 2, Pertemuan 3 The Relational Model Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Sunday, June 28, Entity-Relationship and Enhanced Entity-Relationship Conceptual Data Models (Chapters 6 & Section 7.1)
CS 405G: Introduction to Database Systems Lecture 4: Relational Model Instructor: Chen Qian.
Database Architecture The Relational Database Model.
Sets.
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.
Relational Model Session 6 Course Name: Database System Year : 2012.
1 The Relational Data Model, Relational Constraints, and The Relational Algebra.
Chapter 4 The Relational Model.
Chapter 3 The Relational Model Transparencies Last Updated: Pebruari 2011 By M. Arief
Set Theory. What is a set?  Sets are used to define the concepts of relations and functions. The study of geometry, sequences, probability, etc. requires.
THE RELATIONAL DATA MODEL CHAPTER 3 (6/E) CHAPTER 5 (5/E) 1.
CS 3630 Database Design and Implementation. 2 Mathematical Relation A mathematical relation is a subset of a Cartesian Product. A1  A2  A3  …  An.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database 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.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 6 – September 6 th, 2001.
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.
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
9/7/2012ISC329 Isabelle Bichindaritz1 The Relational Database Model.
CS 103 Discrete Structures Lecture 10 Basic Structures: Sets (1)
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
Slide Chapter 5 The Relational Data Model and Relational Database Constraints.
ICOM 4035 – Data Structures Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 9 – September 18, 2001.
Chapter 2: Basic Structures: Sets, Functions, Sequences, and Sums (1)
Discrete Mathematics Relation.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
1 Section 1.6 Sets. 2 Set Fundamental discrete structure on which all other discrete structures are built Can be loosely defined as a collection of elements.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
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.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Introduction.
ELEMENTARY SET THEORY.
(CSC 102) Lecture 13 Discrete Structures. Previous Lectures Summary  Direct Proof  Indirect Proof  Proof by Contradiction  Proof by Contra positive.
ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 5 – September 4 th,
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com ICOM 5016 – Introduction.
The Relational Model © Pearson Education Limited 1995, 2005 Bayu Adhi Tama, M.T.I.
Module #3 - Sets 3/2/2016(c) , Michael P. Frank 2. Sets and Set Operations.
Chapter 7 Sets and Probability Section 7.1 Sets What is a Set? A set is a well-defined collection of objects in which it is possible to determine whether.
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Intro to Relational.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
Relational Model Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 3.
Set Definition: A set is unordered collection of objects.
Module 2: Intro to Relational Model
Chapter 2: Relational Model
Sets Section 2.1.
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Intro to Relational Model
Data Base System Lecture 6: Relational Model
Chapter 4 The Relational Model Pearson Education © 2009.
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
ICOM 5016 – Introduction to Database Systems
Lecture Sets 2.2 Set Operations.
ICOM 5016 – Introduction to Database Systems
Presentation transcript:

ICOM 6005 – Database Management Systems Design Dr. Manuel Rodríguez Martínez Electrical and Computer Engineering Department Lecture 2 – Relational Model Fundamentals ©Manuel Rodriguez – All rights reserved

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

ICOM 6005Dr. Manuel Rodriguez Martinez3 On Sets and Relations A set S is a collection of objects, where there are no duplicates –Examples A = {a, b, c} B = {0, 2, 4, 6, 8} C = {Jose, Pedro, Ana, Luis} The objects that are part of a set S are called the elements of the set. –Notation: 0 is an element of set B is written as 0  B. 3 is not an element of set B is written as 3  B.

ICOM 6005Dr. Manuel Rodriguez Martinez4 Cardinality of Sets Sets might have –0 elements – called the empty set . –1 elements – called a singleton –N elements – a set of N elements (called a finite set) Ex: S = {car, plane, bike} –  elements – an infinite number of elements (called infinite set) Integers, Real, Even numbers: E = {0, 2, 4, 6, 8, 10, …} –Dot notation means infinite number of elements The cardinality of a set is its number of elements –Notation: cardinality of S is denoted by |S| –Could be an integer number or infinity symbol .

ICOM 6005Dr. Manuel Rodriguez Martinez5 Cardinality of Sets (cont.) Some examples: –A = {a,b,c} |A| = 3 –R – set of real numbers |R| =  –E = {0, 2, 4, 6, 8, 10, …} |E| =  –  the empty set |  | = 0

ICOM 6005Dr. Manuel Rodriguez Martinez6 Set notations and equality of Sets Enumeration of elements of set S –A = {a,b c} –E = {0, 2, 4, 6, 8, 10, …} Enumeration of the properties of the elements in S –E = {x : x is an even integer} –E = {x: x  I and x%2=0, where I is the set of integers.} Two sets are said to be equal if and if only they both have the same elements –A = {a, b, c}, B = {a, b, c}, then A = B –if C = {a, b, c, d}, then A  C Because d  A

ICOM 6005Dr. Manuel Rodriguez Martinez7 Sets and Subsets Let A and B be two sets. B is said to be a subsets of A if and only if every member x of B is also a member of A –Notation: B  A –Examples: A = {1, 2, 3, 4, 5, 6}, B = {1, 2}, then B  A D = {a, e, i, o, u}, F = {a, e, i, o, u}, then F  D –If B is a subset of A, and B  A, then we call B a proper subset Notation: B  A A = {1, 2, 3, 4, 5, 6}, B = {1, 2}, then B  A –The empty set  is a subset of every set, including itself   A, for every set A –If B is not a subset of A, then we write B  A

ICOM 6005Dr. Manuel Rodriguez Martinez8 Set Union Let A and B be two sets. Then, the union of A and B, denoted by A  B is the set of all elements x such that either x  A or x  B. –A  B = {x: x  A or x  B} Examples: –A = {10, 20, 30, 40, 100}, B = {1,2, 10, 20} then A  B = {1, 2, 10, 20, 30, 40, 100} –C = {Tom, Bob, Pete}, then C   = C –For every set A, A  A = A

ICOM 6005Dr. Manuel Rodriguez Martinez9 Set Intersection Let A and B be two sets. Then, the intersection of A and B, denoted by A  B is the set of all elements x such that x  A and x  B. –A  B = {x: x  A and x  B} Examples: –A = {10, 20, 30, 40, 100}, B = {1,2, 10, 20} then A  B = {10, 20} –Y = {red, blue, green, black}, X = {black, white}, then Y  X = {black} –E = {1, 2, 3}, M={a, b} then, E  M =  –C = {Tom, Bob, Pete}, then C   =  For every set A, A  A = A Sets A and B disjoint if and only if A  B =  –They have nothing in common

ICOM 6005Dr. Manuel Rodriguez Martinez10 Set Difference Let A and B be two sets. Then, the difference between A and B, denoted by A - B is the set of all elements x such that x  A and x  B. –A - B = {x: x  A and x  B} Examples: –A = {10, 20, 30, 40, 100}, B = {1,2, 10, 20} then A - B = {30, 40, 100} –Y = {red, blue, green, black}, X = {black, white}, then Y - X = {red, blue, green} –E = {1, 2, 3}, M={a, b} then, E - M = E –C = {Tom, Bob, Pete}, then C -  = C –For every set A, A - A = 

ICOM 6005Dr. Manuel Rodriguez Martinez11 Power Set and Partitions Power Set: Given a set A, then the set of all possible subsets of A is called the power set of A. –Notation: –Example: A = {a, b, 1} then = { , {a}, {b}, {1}, {a,b}, {a,1}, {b,1}, {a,b,1}} Note: empty set is a subset of every set. Partition: A partition  of a nonempty set A is a subset of such that –Each set element P   is not empty –For D, F  , D  F, it holds that D  F =  –The union of all P   is equal to A. –Example: A = {a, b, c}, then  = {{a,b}, {c}}. Also  = {{a}, {b}, {c}}. But this is not: M = {{a, b}, {b}, {c}}

ICOM 6005Dr. Manuel Rodriguez Martinez12 Cartesian Products and Relations Cartesian product: Given two sets A and B, the Cartesian product between and A and, denoted by A x B, is the set of all ordered pairs (a,b) such a  A and b  B. –Formally: A x B = {(a,b): a  A and b  B} –Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b), (2,a), (2,b)}. A binary relation R on two sets A and B is a subset of A x B. –Example: A = {1, 2}, B = {a, b}, then A x B = {(1,a), (1,b), (2,a), (2,b)}, and one possible R  A x B = {(1,a), (2,a)}

ICOM 6005Dr. Manuel Rodriguez Martinez13 N-ary Relations Let A1, A2, …, An be n sets, not necessarily distinct, then an n-ary relation R on A1, A2, …, An is a sub- set of A1 x A2 x … x An. –Formally: R  A1 x A2 x … x An –R = {(a1, a2, …,an) : a1  A1 and a2  A2 and … and an  An} –Example: R = set of all real numbers R x R x R = three-dimensional space P = {(x, y, z): x  R and x  0 and y  R and y  0 and y  R and y  0} = Set of all three-dimensional points that have positive coordinates

ICOM 6005Dr. Manuel Rodriguez Martinez14 The Relational Model of Data id nameageaddress 123Bob19San Juan 45678Tim53New York Mary25Miami Representing information about customers for a store. Data is viewed in tabular form This is equivalent to a relation

ICOM 6005Dr. Manuel Rodriguez Martinez15 The Relational Model of Data Proposed in 1970 by E.F. Codd Models a data set as a table –Each column represent a value –Each row represents a group of values that represent a relationship. This relationship describes a given entity. Thus every row in a table describes an entity. –Columns are often called attributes because they describe information about the entity described in the row. –Rows are often called records. –Rows are also called tuples, because they are elements in a relation formed by the set of attributes associated with the table.

ICOM 6005Dr. Manuel Rodriguez Martinez16 Formal Model Let A1, A2, …, An be sets of attributes, then a relation R is a subset of A1 x A2 x … x An –R  A1 x A2 x A3 x … x An –Each Ai is called a domain of the relation –Each element r of R is called a n-tuple or simply a tuple –Each r in R is of the form (a1, a2, …,an) where a1  A1, a2  A2, …, an  An. Each relation has a: –relational schema Definition of the structure of the relation R –Relational instance A set of tuples that form a case of the relation under the defined schema

ICOM 6005Dr. Manuel Rodriguez Martinez17 Relation Schema Describes the name and columns in a relation Components of the schema: –Relation name –Name of each attribute (also called column or field) –Domain of each attribute Described by domain name (often type name) and values. Example: –costumers(id:string, name:string,age:integer,address:string); Name: costumers Attributes: id, name, age, address Domains: strings and integers

ICOM 6005Dr. Manuel Rodriguez Martinez18 Relation Instance A set of tuples (records) in which each tuple has the same number of attributes as in the schema. Example: –Schema costumers(id:string, name:string,age:integer,address:string); –Instance of Customer id nameageaddress 123Bob19San Juan 45678Tim53New York Mary25Miami

ICOM 6005Dr. Manuel Rodriguez Martinez19 Relation cardinality and degree Cardinality – number of tuples in the relation R Degree – number of attributes in the relation R. Also called the arity of the relation R. Example: –cardinality = 3, degree = 4 id nameageaddress 123Bob19San Juan 45678Tim53New York Mary25Miami

ICOM 6005Dr. Manuel Rodriguez Martinez20 Keys on a relation superkey – a set of one or more attributes that uniquely identify a tuple r in a relation R. –Minimal superkey – a key from which if we remove an attribute X, it would no longer be a superkey. candidate keys – set of all minimal superkeys in a relation R. primary key – a candidate key that the database designer chooses as the means to identify the tuples in a relation R.

ICOM 6005Dr. Manuel Rodriguez Martinez21 Examples of keys –Super keys: {id,name}, {id, name, address} –candidate key: {id} –primary key: {id} id nameageaddress 123Bob19San Juan 45678Tim53New York 1253Joe19Los Angeles 37322Bob30San Juan Mary25Miami