© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.

Slides:



Advertisements
Similar presentations
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Relational Algebra, Join and QBE Yong Choi School of Business CSUB, Bakersfield.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
Relational Database. Relational database: a set of relations Relation: made up of 2 parts: − Schema : specifies the name of relations, plus name and type.
Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra.
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A Modified by Donghui Zhang.
INFS614, Fall 08 1 Relational Algebra Lecture 4. INFS614, Fall 08 2 Relational Query Languages v Query languages: Allow manipulation and retrieval of.
Relational Algebra 1 Chapter 5.1 V3.0 Napier University Dr Gordon Russell.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 2 Structured Query Language.
Midterm Review Lecture 14b. 14 Lectures So Far 1.Introduction 2.The Relational Model 3.Disks and Files 4.Relational Algebra 5.File Org, Indexes 6.Relational.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 8 Foundations of Relational Implementation.
Relational Algebra Relational Calculus. Relational Algebra Operators Relational algebra defines the theoretical way of manipulating table contents using.
Database Management Systems, R. Ramakrishnan and J. Gehrke1 Relational Algebra Chapter 4, Part A.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 8 Foundations of Relational Implementation.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Relational Algebra Chapter 4 - part I. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.  Relational.
1-1 Thomas Connolly and Carolyn Begg’s Database Systems: A Practical Approach to Design, Implementation, and Management Chapter 4 Part One: Relational.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
The Relational Database Model
Concepts of Database Management, Fifth Edition
1 Relational Algebra and Calculus Chapter 4. 2 Relational Query Languages  Query languages: Allow manipulation and retrieval of data from a database.
HAP 709 – Healthcare Databases SQL Data Manipulation Language (DML) Updated Fall, 2009.
(C) 2000, The University of Michigan 1 Database Application Design Handout #4 January 28, 2000.
Chapter 5 The Relational Model and Normalization David M. Kroenke Database Processing © 2000 Prentice Hall.
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.
Concepts of Database Management Seventh Edition
Relational Algebra References: Databases Illuminated by Catherine Ricardo, published by Jones and Bartlett in 2004 Fundamentals of Relational Databases.
Feb 2001CSS/416:Module U1 Workshop 11 CSS/416 Data Design And Information Retrieval Workshop 1.
Chapter 8 Foundations of Relational Implementation David M. Kroenke Database Processing © 2000 Prentice Hall.
Relational Algebra CS420. Relation A relation is a two dimensional table that Rows contain data about an entity Columns contains data about attributes.
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
Chapter 9 Structured Query Language David M. Kroenke Database Processing © 2000 Prentice Hall.
© Jalal Kawash Database Queries Peeking into Computer Science.
1 Relational Algebra and Calculas Chapter 4, Part A.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 7 (Part a): Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
1 Relational Algebra Chapter 4, Sections 4.1 – 4.2.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
DBSQL 5-1 Copyright © Genetic Computer School 2009 Chapter 5 Structured Query Language.
Relational Algebra MBAD 613 R. Nakatsu. Relational Data Manipulation Language Query-by-Example; Query-by-Form Transform-Oriented Languages Relational.
Advanced Relational Algebra & SQL (Part1 )
(C) 2000, The University of Michigan 1 Database Application Design Handout #5 February 4, 2000.
Database Management Systems, R. Ramakrishnan1 Relational Algebra Module 3, Lecture 1.
CMPT 258 Database Systems The Relationship Model (Chapter 3)
1 2 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 2 The Relational Model 1: Introduction, QBE, and Relational Algebra.
Lecture 10 Creating and Maintaining Geographic Databases Longley et al., Ch. 10, through section 10.4.
(SQL - Structured Query Language)
1 Announcements Reading for next week: Chapter 4 Your first homework will be assigned as soon as your database accounts have been set up.  Expect an .
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL and Relational Algebra Edel Sherratt Nigel Hardy Horst Holstein.
Understanding Core Database Concepts Lesson 1. Objectives.
CH 9 SQL 9.1 Querying A Single Table 9.2 Querying Multiple Tables
Ch 8: Foundations of Relational Implementation
Chapter 4 Relational Databases
Relational Algebra 461 The slides for this text are organized into chapters. This lecture covers relational algebra, from Chapter 4. The relational calculus.
The Relational Model and Normalization
Relational Algebra References:
More Relational Algebra
SQL Fundamentals in Three Hours
DATABASE Purpose of database
Understanding Core Database Concepts
Presentation transcript:

© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev

© 2002 by Prentice Hall 2 David M. Kroenke Database Processing Eighth Edition Chapter 8 Foundations of Relational Implementation

© 2002 by Prentice Hall 3 Review Relational Model Terminology Relation is a two-dimensional table Attributes are single valued Each attribute belongs to a domain –A domain is a physical and logical description of permittable values No two rows are identical Order is unimportant The row is called a tuple

© 2002 by Prentice Hall 4 Data Definition Language (DDL) In order to create the tables and structures within a database, the DBMS must provide (often using SQL) a data definition language (DDL). The DDL is used to define (i.e., Create, Drop, and Alter) everything in the database… –Tables –Columns –Indexes –Users, etc.

© 2002 by Prentice Hall 5 Data Manipulation Language (DML) When thinking about SQL, most people think of the Data Manipulation Language (DML) aspects of the language The DML allows users to insert, delete, modify, and retrieve information –Select –Delete –Insert –Update

© 2002 by Prentice Hall 6 DML Alternatives A DBMS must provide at least one DML. Several options exist… –Query/Update language (e.g., SQL) –Query-by-Example –Query-by-Form

© 2002 by Prentice Hall 7 Query/Update Language SELECT Name, Age FROM PATIENT WHERE Physician = ‘Levy’

© 2002 by Prentice Hall 8 Query by Form

© 2002 by Prentice Hall 9 Application Program Interface (API) Some applications provide an Application Program Interface (API) The API is a DML typically used by programmers To retrieve or update data contained within the application, a programmer submits requests to the application’s API.

© 2002 by Prentice Hall 10 Relational Algebra Relational algebra defines a set of operators that may work on relations. Recall that relations are simply data sets. As such, relational algebra deals with set theory. The operators in relational algebra are very similar to traditional algebra except that they apply to sets.

© 2002 by Prentice Hall 11 Relational Algebra Operators Relational algebra provides several operators: –Union –Difference –Intersection –Product –Projection –Selection –Join

© 2002 by Prentice Hall 12 Union Operator The union operator adds tuples from one relation to another relation A union operation will result in combined relation This is similar to the logical operator ‘OR’

© 2002 by Prentice Hall 13 Union Operator JUNIOR and HONOR-STUDENT relations and their union: (a)Example of JUNIOR relation (b)Example HONOR- STUDENT relation (c)Union of JUNIOR and HONOR- STUDENT relations

© 2002 by Prentice Hall 14 Difference Operator The difference operator produces a third relation that contains the tuples that appear in the first relation, but not the second This is similar to a subtraction

© 2002 by Prentice Hall 15 Difference Operator JUNIOR relation HONOR- STUDENT relation JUNIOR minus HONOR- STUDENT relation

© 2002 by Prentice Hall 16 Intersection Operator An intersection operation will produce a third relation that contains the tuples that are common to the relations involved. This is similar to the logical operator ‘AND’

© 2002 by Prentice Hall 17 Intersection Operator JUNIOR relation HONOR- STUDENT relation Intersection of JUNIOR and HONOR- STUDENT relations

© 2002 by Prentice Hall 18 Product Operator A product operator is a concatenation of every tuple in one relation with every tuple in a second relation The resulting relation will have n x m tuples, where… n = the number of tuples in the first relation and m = the number of tuples in the second relation This is similar to multiplication

© 2002 by Prentice Hall 19 Projection Operator A projection operation produces a second relation that is a subset of the first. The subset is in terms of columns, not tuples The resulting relation will contain a limited number of columns. However, every tuple will be listed.

© 2002 by Prentice Hall 20 Selection Operator The selection operator is similar to the projection operator. It produces a second relation that is a subset of the first. However, the selection operator produces a subset of tuples, not columns. The resulting relation contains all columns, but only contains a portion of the tuples.

© 2002 by Prentice Hall 21 Join Operator The join operator is a combination of the product, selection, and projection operators. There are several variations of the join operator… –Equijoin –Natural join –Outer join Left outer join Right outer join

© 2002 by Prentice Hall 22 Data for Join Examples SIDNameMajorGradeLevel 123JonesHistoryJR 158ParksMathGR 271SmithHistoryJR 105AndersonManagementSN StudentNumberClassNamePositionNumber 123H BA B4907

© 2002 by Prentice Hall 23 Join Examples Equijoin Natural Join Left Outer Join

© 2002 by Prentice Hall 24 Expressing Queries in Relational Algebra 1. What are the names of all students? STUDENT [Name] 2. What are the student numbers of all students enrolled in a class? ENROLLMENT [StudentNumber]

© 2002 by Prentice Hall 25 Expressing Queries in Relational Algebra 3. What are the student numbers of all students not enrolled in a class? STUDENT [SID] – ENROLLMENT [StudentNumber] 4. What are the numbers of students enrolled in the class ‘BD445’? ENROLLMENT WHERE ClassName = ‘BD445’[StudentNumber]

© 2002 by Prentice Hall 26 Expressing Queries in Relational Algebra 5. What are the names of the students enrolled in class ‘BD445’? STUDENT JOIN (SID = StudentNumber) ENROLLMENT WHERE ClassName = ‘BD445’[STUDENT.Name]

© 2002 by Prentice Hall 27 Expressing Queries in Relational Algebra 6. What are the names and meeting times of ‘PARKS’ classes? STUDENT WHERE Name = ‘PARKS’ JOIN (SID=StudentNumber) ENROLLMENT JOIN (ClassName = Name) CLASS [CLASS.Name, Time]

© 2002 by Prentice Hall 28 Expressing Queries in Relational Algebra 7. What are the grade levels and meeting rooms of all students, including students not enrolled in a class? STUDENT LEFT OUTER JOIN (SID = StudentNumber) ENROLLMENT JOIN (ClassName = Name) CLASS [GradeLevel, Room]

© 2002 by Prentice Hall 29 Summary of Relational Algebra Operators