Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.

Slides:



Advertisements
Similar presentations
Chapter 3: Relational Model
Advertisements

Chapter 3 : Relational Model
Relational Algebra Dashiell Fryer. What is Relational Algebra? Relational algebra is a procedural query language. Relational algebra is a procedural query.
Ver 1,12/09/2012Kode :CCs 111,sistem basisdataFASILKOM Chapter 2: Relational Model Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 6 The Relational Algebra and Relational Calculus.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. Relational Model Database Management Systems I Alex Coman, Winter 2006.
Relational Model. 2 Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional Relational-Algebra-Operations Extended Relational-Algebra-Operations.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Relational Algebra Instructor: Mohamed Eltabakh 1.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
CSE314 Database Systems The Relational Algebra and Relational Calculus Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E Pearson Ed Slide Set.
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,
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational Calculus Domain Relational.
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING COLLEGE TIRUVANNAMALAI.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
Chapter 2: Relational Model. 2.2 Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional Relational-Algebra-Operations.
Chapter 2: Relational Model. 2.2Unite International CollegeDatabase Management Systems Chapter 2: Relational Model Structure of Relational Databases Fundamental.
Chapter 2: Relational Model II Relational Algebra basics Relational Algebra basics.
Computing & Information Sciences Kansas State University Friday, 26 Jan 2008CIS 560: Database System Concepts Lecture 2 of 42 Friday, 29 August 2008 William.
2.1 Chapter 2: Relational Model. 2.2 Chapter 2: Relational Model Structure of Relational Databases Fundamental Relational-Algebra-Operations Additional.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
Database System Concepts, 5 th Ed. Bin Mu at Tongji University Chapter 2: Relational Model.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
IS 230Lecture 7Slide 1 Relational Algebra Lecture 8 Text Book – Chapter.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Query Languages Language in which user requests information from the database. Categories of languages Procedural Non-procedural, or declarative “Pure”
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan Chapter 2: Relational Model.
CSE202 Database Management Systems
Midlands State University Topic: Relational DB Model
Chapter 3: Relational Model
Module 2: Intro to Relational Model
Relational Algebra.
Chapter # 6 The Relational Algebra and Calculus
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Relational Algebra - Part 1
Chapter 3: Relational Model III
Chapter 6: Formal Relational Query Languages
Chapter 3: Relational Model
Chapter 3: Relational Model
Chapter 2: Intro to Relational Model
Chapter 3: Relational Model
Introduction to Database
Chapter 2: Relational Model
Lecture 4 of 42 Relational Joins Wednesday, 30 January 2008
Introduction to Database
The Relational Algebra and Relational Calculus
Chapter 3: Relational Model
Session 3 Welcome: To session 3-the second learning sequence
Instructor: Mohamed Eltabakh
Chapter 3: Relational Model
Chapter 3: Relational Model
Chapter 3: Relational Model
Chapter 2: Intro to Relational Model
Relational Algebra.
Chapter 2: Intro to Relational Model
Chapter 3: Relational Model
Chapter 2: Intro to Relational Model
Chapter 2: Relational Model
Chapter 6: Formal Relational Query Languages
Example of a Relation attributes (or columns) tuples (or rows)
Chapter 2: Intro to Relational Model
Chapter 3: Relational Model
Lecture 2 Relational Database
Presentation transcript:

Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy

Introduction Relational database theory assist in definition of databases and in efficient processing of databases and in efficient processing of user requests for information from a database. ER model defined the problem and leads us to the tables. Now we need to define, manipulate and use the tables.. Relational model provides the foundation for this. 5/28/2019 B.Ramamurthy

Topics for Discussion Structure of Relational database Relational Algebra Tuple Relational Calculus Domain Relational Calculus Extended Relational-Algebra-Operations Modifications of the Database Views Summary 5/28/2019 B.Ramamurthy

Relational Database A relational database consists of a collection of tables, each of which is assigned a unique name. A table will be referred to as a relation in Relational DB. Tuple is the term for row in a table. On to more theoretical stuff … 5/28/2019 B.Ramamurthy

Basic Structure Given sets A1, A2, A3…An, a relation r is a subset of A1 X A2 X A3 X ….X An A relation is a set of n-tuples (a1,a2,a3,..an) where ai Є Ai. Example : if customer-name = {Jones, Smith, Curry, Lindsay} customer-street = {Main, North, Park} customer-city = {Harrison, Rye, Pittsfield} Then r = {(Jones,Main,Harrison), (Smith,North,Rye), {Curry,North,Rye), (Lindsay, Park, Pittsfield)} is a relation over customer-name X customer-street X customer-city 5/28/2019 B.Ramamurthy

Relation Schema (This concept is analogous to class, instance of a class in OOP) A1, A2, A3.. An are attributes R = (A1, A2, A3, …An) is a relation schema. Example : Customer-schema = (customer-name, customer-street, customer-city) r(R) is a relation on the relational schema R Example : customer(Customer-schema) 5/28/2019 B.Ramamurthy

More Examples Branch-scheme= (banch-name, branch-city,assets) Relation is a table of specific branches branch-name branch-city assets Downtown Brooklyn 90000000 Redwood Palo Alto 89760000 North Town Rye 37900000 5/28/2019 B.Ramamurthy

Relation Instance Current values (relational instance) of a relation are specified by a table. An element t of r is a tuple: represented by a row in the “relation” table See the above example 5/28/2019 B.Ramamurthy

Query Language Language in which user requests information from a database. Categories of languages: procedural, non procedural Pure Languages: Relational algebra Tuple relational calculus Domain relational calculus Pure languages form the basis of query languages. 5/28/2019 B.Ramamurthy

Relational Algebra Procedural Language Six fundamental operations Select Project Union Set difference Cartesian product Rename The operators take two or more relations as inputs and give a new relation as a result. 5/28/2019 B.Ramamurthy

Select Operation Select operation selects tuples that satisfy a given predicate. Lowercase sigma is used to denote selection. The predicate appears as subscript to p The argument relation is given in parenthesis. Therefor notation for Select operation is p (r) 5/28/2019 B.Ramamurthy

Select: Formal Definition P ( r ) = {t | t Є r and P(t)} where t is a tuple in r that satisfies P(t) P(t) is a formula in propositional calculus, dealing with terms of the form: <attribute> op <attribute> or constant op represents an operator in { =, <>, > , >=, <=} simple terms can be connected by and, or, not 5/28/2019 B.Ramamurthy

Select: Example c Relation r : A B C D   1 7 5 12 3 23 10   A= B and D > 5 (r )   23 10 5/28/2019 B.Ramamurthy

Project Operation Suppose you are interested in retrieving only a few attributes of a relation. A “Project” operation can be used. It is a unary operation. Basically a vertical subset of a table is returned. Duplicate rows are removed from the result. 5/28/2019 B.Ramamurthy

Project: Formal Definition A1,A2,…Ak ( r ) where A1, A2, …Ak are attribute names and r is a relation name. Result has k columns, each column representing an attribute. 5/28/2019 B.Ramamurthy

Project: Example A B C D Relation r :   1 7 5 7 12 3   23 10   A,B ( r ) 5/28/2019 B.Ramamurthy

Union Operation Binary operation. Notation : r U s Definition: r U s = {t | t Є r or t Є s} Constraints are: 1. r and s must have same arity (same number of attributes) 2. The attribute domains must be compatible (ex: 2 nd column of r is of String type and so should 2nd column of s) 5/28/2019 B.Ramamurthy

Union: Example  1  2 s r   2 3 r U s  1   2 1  3 A B A B A B 5/28/2019 B.Ramamurthy

Other Important Operations We discussed Join, Division, Cartesian Product, Rename and Assignment operations. For each of these we studied: 1. The symbol 2. Formal expression 3. An example in tabular form 4. A sample query that needs (or uses) this operation. 5/28/2019 B.Ramamurthy

Tuple Relational Calculus A nonprocedural query language, where each query is of the form { t | P(t) } It is the set of all tuples t such that predicate P is true for t. t is a tuple variable; t[ A] denotes the value of tuple t on attribute A and t  r denotes that tuple t is in relation r. P is a formula similar to that of the predicate calculus. 5/28/2019 B.Ramamurthy

Sample Queries {t | t  loan  t[amount] > 1200} Write the following in tuple relational calculus as well as in relational algebra. Loan numbers such that loan-amount > 1200 Names of all customers who have a loan from the PerryRidge branch. 5/28/2019 B.Ramamurthy

Extended Relational Algebra Operations Generalized projection: Apply arithmetic (or any) function to the regular projection. Example : Credit info of customers. Outer Join: Extension of join that deals with missing information. Lossless join. We have left outer join and right outer join. Aggregate functions: to take a collection of values and return a single value. Example : sum of a column. 5/28/2019 B.Ramamurthy

Modification of the database Deletion, insertion, updating : all these major operations are actual a collection of lower level operations we have discussed. Views: View definitions will also have only part of the data stored in the table depending on the request. Once again we apply the project , join and other operations we studied. 5/28/2019 B.Ramamurthy

Summary A relational database is made up of tables. Each table is a relation. Each row of a table is a relationship. E-R diagram --> relation-schema--> tables --> RDB Relational operations are used to extract data from the tables. 5/28/2019 B.Ramamurthy