1 The Relational Model By Elena Ciriani CS157A February 19, 2004 Professor Lee.

Slides:



Advertisements
Similar presentations
Relational Algebra Dashiell Fryer. What is Relational Algebra? Relational algebra is a procedural query language. Relational algebra is a procedural query.
Advertisements

Relational Databases - Amit Bhawnani & Nimesh Shah.
CS4432: Database Systems II Query Operator & Algebraic Expressions 1.
Domain Relational Calculus and Query-by-Example CS157a John Eagle.
Chapter 2 Relational Model (part II) Hankz Hankui Zhuo
The Relational Database Model
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Extended.
SQL Sangeeta Devadiga CS157A, Fall Outline Background Data Definition Basic Structure Set Operation.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational.
SQL Structured Query Language Meizhen Huang. Content (4.1 – 4.4) Background Parts of SQL Basic Structure Set Operations Aggregate Functions.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational.
Chapter 3: Relational Model
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Multimedia Information Systems CS Outlines Introduction to DMBS Relational database and SQL B + - tree index structure.
SPRING 2004CENG 3521 E-R Diagram for the Banking Enterprise.
Slides adapted from A. Silberschatz et al. Database System Concepts, 5th Ed. SQL - part 2 - Database Management Systems I Alex Coman, Winter 2006.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Midterm 2 Revision Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Relational Algebra. Relational Query Languages n Query = “retrieval program” n Language examples: ù Theoretical : 1. Relational Algebra 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.
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Chapter 4: SQL Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries.
SQL. Basic Structure SQL is based on set and relational operations with certain modifications and enhancements A typical SQL query has the form: select.
©Silberschatz, Korth and Sudarshan3.1Database System Concepts Chapter 3: Relational Model Structure of Relational Databases Relational Algebra Tuple Relational.
Lecture 6 Structured Query Language SQL Lecture 6 Structured Query Language SQL Instructor: Haya Sammaneh.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Basic Structure Given sets A 1, A 2,..., A n a relation r is a subset of A 1 x A 2 x... x A n Thus a relation is a set of n-tuples (a 1, a 2,..., a n )
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Relational Model: Examples. Banking Example branch (branch_name, branch_city, assets) customer (customer_name, customer_street, customer_city) account.
Relational Algebra Instructor: Mohamed Eltabakh 1.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Chapter 3: Relational Model  Structure of Relational Databases  Normal forms (chap. 7)  Reduction of an E-R Schema to Relational (Sect. 2.9)  Relational.
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,
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
CIS552Relational Model1 Structure of Relational Database Relational Algebra Extended Relational-Algebra-Operations Modification of the Database.
CS 370 Database Systems Lecture 11 Relational Algebra.
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 Sudarshan5.1Database System Concepts Chapter 5: Other Relational Query Languages Tuple Relational Calculus Domain Relational Calculus.
©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 8: SQL. Data Definition Modification of the Database Basic Query Structure Aggregate Functions.
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. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
Database System Concepts, 5 th Ed. Bin Mu at Tongji University Chapter 2: Relational Model.
Computing & Information Sciences Kansas State University Wednesday, 03 Sep 2008CIS 560: Database System Concepts Lecture 3 of 42 Wednesday, 03 September.
Presented By: Miss N. Nembhard. Relation Algebra Relational Algebra is : the formal description of how a relational database operates the mathematics.
Relational Algebra HW2 Turn in as a hardcopy at the start of next class period. You may work this assignment in groups.
ICOM 5016 – Introduction to Database Systems Lecture 6 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
1 Session 3 Welcome: To session 3-the fourth learning sequence “Relational algebra “ Recap : In the previous learning sequences, we discussed the four.
ASET Relational Algebra continues…. ASET Rename Operation Allows us to name, and therefore to refer to, the results of relational-algebra expressions.
Database System Concepts, 5 th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 2: Relational.
IS 230Lecture 7Slide 1 Relational Algebra Lecture 8 Text Book – Chapter.
International Computer Institute, Izmir, Turkey Relational Model Asst.Prof.Dr.İlker Kocabaş UBİ502 at
Relational Algebra Instructor: Mohamed Eltabakh 1.
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.
Midlands State University Topic: Relational DB Model
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Instructor: Mohamed Eltabakh
Chapter 2: Intro to Relational Model
Relational Model B.Ramamurthy 5/28/2019 B.Ramamurthy.
CS 405G: Introduction to Database Systems
Presentation transcript:

1 The Relational Model By Elena Ciriani CS157A February 19, 2004 Professor Lee

2 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.

3 TOPICS Structure of Relational database –A row in a table represents a relationship among a set of values where the columns are the representation of the attributions The Relational Algebra –It defines a set of algebraic operations that operate on tables, and output tables as their results. These operations can be combined to get expressions that express desired queries.

4 Structure of Relational Database (Section 3.1) Basic Structure Database Schema Keys Schema Diagram Query Languages

5 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.

6 Database Schema 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 Relation instance is the programming language notion of a value of a variable

7 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)

8 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.

9 Keys 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 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

10 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

11 How to determine keys 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 Relation set: the union of the primary keys of the related entity sets becomes a superkey of the relation

12 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 Multivalued attributes: the entity primary key becomes the primary key

13 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

14 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

15 The Relational Algebra Topics (section 3.2) Fundamental Operations – The Select Operation – The Project Operation – Composition of Relational Operations – The Union Operation – The Set Difference Operation – The Cartesian-Product Operation – The Rename Operation

16 Relational Algebra The relational algebra is a pure procedural query language. It consists of a set of operations that take one or two relations as input in an expression and produced a new relation as their result. A constant relation is written inside {} A general expression is construct in subexpressions If they works on one relation are called unary operation otherwise are said to be binary

17 Unary Operations Select operation: choose the tuples that satisfy a given predicament. –σ branch-name = “Perryridge”(loan) Project operation: allows the user to select particular attributes of a relationship –Π loan-number, amount (loan) Rename operation: give a name to the results of relational algebra expressions – ρ big-loans (σ amount > 1200 (loan))

18 Binary Operation Union operation: allows the user to unify two different relations and display the result –Π customer-name (borrower) U Π customer-name (depositor) Difference operation: finds the tuples that are in one relation but not in another –Π customer-name (borrower) - Π customer-name (depositor)

19 Binary Operation Cartesian-product: combines information from any two relations –σ branch-name = “Perryridge”(borrower x loan) Composition of operation: means that to find information we can associate more operation into an expression –Π customer-name (σ customer-city = “Harrison”(customer))

20 The Relational Algebra (continued) (Section 3.2.3) Additional Operations The following operations make a relational algebra query easier when the basic expression may become lengthy – The Set-Intersection Operation – The Natural-Join Operation – The Division Operation – The Assignment Operation

21 Additional Operation Set-Intersection Operation: find all the attributes that appear in both relations –Π customer-name (borrower) ∩ Π customer-name (depositor) –Π customer-name (borrower) – (Π customer-name (borrower) – Π customer-name (depositor))

22 Additional Operation Natural-Join Operation: forms a Cartesian product of its two arguments, performs a selection forcing equality on those attributes that appears in both relations and removes any duplicates –Π customer-name, loan-number, amount (borrower loan) –Π customer-name, loan-number, amount ( borrower.loan-number = loan.loan-number (borrower x loan))

23 Additional Operation Division operation: is suited to queries that include the phrase “for all” –Π customer-name, branch-name (depositor account) Π branch-name (σ branch-city = “Brooklyn”(branch))

24 Additional Operation Assignment operation: write part of a relational expression to a temporary relation variable. This variable is used later in expression of a query –temp1 ← Πcustomer-name (borrower) –temp2 ← Πcustomer-name (depositor) –Result = temp1 – (temp1 – temp2)