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

Slides:



Advertisements
Similar presentations
Foundations of Relational Implementation (1) IS 240 – Database Management Lecture #13 – Prof. M. E. Kabay, PhD, CISSP Norwich University
Advertisements

Relational Database and Data Modeling
Implementation of the Relational Model
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Basic SQL Introduction Presented by: Madhuri Bhogadi.
Foundations of Relational Implementation n Defining Relational Data n Relational Data Manipulation n Relational Algebra.
Concepts of Database Management Sixth Edition
Brian Alderman | MCT, CEO / Founder of MicroTechPoint Pete Harris | Microsoft Senior Content Publisher.
Introduction to Structured Query Language (SQL)
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 2 Structured Query Language.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 8 Foundations of Relational Implementation.
Introduction to Structured Query Language (SQL)
Database Management: Getting Data Together Chapter 14.
Fundamentals, Design, and Implementation, 9/e Chapter 11 Managing Databases with SQL Server 2000.
Getting Started (Excerpts) Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
A Guide to SQL, Seventh Edition. Objectives Understand the concepts and terminology associated with relational databases Create and run SQL commands in.
Introduction to Structured Query Language (SQL)
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2003 Dragomir R. Radev.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 7-1 David M. Kroenke’s Chapter Seven: SQL for Database Construction and.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
Getting Started Chapter One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Database Lecture # 1 By Ubaid Ullah.
Copyright © 2003 by Prentice Hall Module 4 Database Management Systems 1.What is a database? Data hierarchy and data organization Field, record, file,
RDB/1 An introduction to RDBMS Objectives –To learn about the history and future direction of the SQL standard –To get an overall appreciation of a modern.
Database Technical Session By: Prof. Adarsh Patel.
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.
© 2007 by Prentice Hall (Hoffer, Prescott & McFadden) 1 Introduction to SQL.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 UNIT 6: Chapter 7: Introduction to SQL Modern Database Management 9 th Edition Jeffrey A.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Chapter 15 Relational Implementation with DB2 David M. Kroenke Database Processing © 2000 Prentice Hall.
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.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
Getting Started Chapter One DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Feb 2001CSS/416:Module U1 Workshop 11 CSS/416 Data Design And Information Retrieval Workshop 1.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Chapter 8 Foundations of Relational Implementation David M. Kroenke Database Processing © 2000 Prentice Hall.
Chapter 9 Structured Query Language David M. Kroenke Database Processing © 2000 Prentice Hall.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
© 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 Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Creating and Maintaining Geographic Databases. Outline Definitions Characteristics of DBMS Types of database Relational model SQL Spatial databases.
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Concepts 2440: 180 Database Concepts Instructor:
Implementation of the Relational Model There is no substitute for the comfort supplied by the utterly taken-for-granted relationship. Iris Murdoch.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Relational Algebra MBAD 613 R. Nakatsu. Relational Data Manipulation Language Query-by-Example; Query-by-Form Transform-Oriented Languages Relational.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
Lecture 10 Creating and Maintaining Geographic Databases Longley et al., Ch. 10, through section 10.4.
DBMS 3. course. Reminder Data independence: logical and physical Concurrent processing – Transaction – Deadlock – Rollback – Logging ER Diagrams.
©2003 Prentice Hall Business Publishing, Accounting Information Systems, 9/e, Romney/Steinbart 4-1 Relational Databases.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
Chapter 3: Relational Databases
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
CSC314 DAY 8 Introduction to SQL 1. Chapter 6 © 2013 Pearson Education, Inc. Publishing as Prentice Hall SQL OVERVIEW  Structured Query Language  The.
1 Database Fundamentals Introduction to SQL. 2 SQL Overview Structured Query Language The standard for relational database management systems (RDBMS)
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
SQL Basics Review Reviewing what we’ve learned so far…….
Ch 8: Foundations of Relational Implementation
Relational Model By Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany)
Chapter 4 Relational Databases
Accounting Information Systems 9th Edition
Chapter 8 Advanced SQL.
Presentation transcript:

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

© 2002 by Prentice Hall 2 Implementing a Relational Database 1.Define structure to DBMS 2.Allocate space 3.Create & load data

© 2002 by Prentice Hall 3 Accomplished Via “Smaller” RDBMS –Graphical User Interface “Larger” RDBMS 1.Data Definition Language 2.Data Manipulation Language 3.Data Control Language

© 2002 by Prentice Hall 4 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

© 2002 by Prentice Hall 5 Logical Key versus Physical Key The term ‘key’ is ambiguous During the design phase, ‘key’ is used to describe candidate keys –Design-phase keys are logical keys During the implementation phase, ‘key’ is any column for which there is an index – Implementation-phase keys are physical keys

© 2002 by Prentice Hall 6 Indexes Overhead data used to: –improve access –improve sorting performance –enforce uniqueness Single column or group of columns

© 2002 by Prentice Hall 7 Indexes

© 2002 by Prentice Hall 8 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, Attributes, Constraints –Relationships –Indexes

© 2002 by Prentice Hall 9 DDL EXAMPLE SCHEMA for BASEBALL RDB TEAM (Name, City); Name, City: Text, cannot be null Sort capability on Name and/or City TEAM Name City

© 2002 by Prentice Hall 10 DDL EXAMPLE CREATE SCHEMA BASEBALL; CREATE TABLE TEAM ( NAME VARCHAR2(20) NOT NULL, CITYVARCHAR2(50) NOT NULL, CONSTRAINT TEAMNAME_PK PRIMARY KEY(NAME) ); CREATE INDEX CITY_IX ON TEAM(CITY); GRANT SELECT ON TEAM TO PUBLIC;

© 2002 by Prentice Hall 11 DDL EXAMPLE CREATE SCHEMA: Creates a “Name Space” Baseball.Team.Name, Baseball.Team.City, etc CREATE TABLE, Attributes & Constraints CREATE PRIMARY KEY & other INDEX(es)

© 2002 by Prentice Hall 12 Data Control Language (DCL) Commands used to control database, including administering privileges and committing (saving) data Occurs concurrently with DDL & DML

© 2002 by Prentice Hall 13 DCL Example CREATE SCHEMA BASEBALL; CREATE TABLE TEAM ( NAME VARCHAR2(20) NOT NULL, CITYVARCHAR2(50) NOT NULL, CONSTRAINT TEAMNAME_PK PRIMARY KEY(NAME) ); CREATE INDEX CITY_IX ON TEAM(CITY); GRANT SELECT ON TEAM TO PUBLIC;

© 2002 by Prentice Hall 14 Space Allocation May be handled automatically (Access) or Organizational standards If not, requires –Normalized relations –Volume estimates –Attribute definitions –Usage Analysis –Data security, backup, recovery, retention

© 2002 by Prentice Hall 15 Space Allocation Usage Analysis: –Where, when, how often: data entry, retrieval, deletion, update Order Order Line Part Supplier

© 2002 by Prentice Hall 16 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 17 Create and Load Data Goal is to use DML as much as possible But often requires manual keypunch

© 2002 by Prentice Hall 18 DML Alternatives Relational Algebra Relational Calculus Non-Procedural, Transform Oriented (i.e. SQL) QBE / QBF

© 2002 by Prentice Hall 19 Most common DMLs Most RDBMSs provide one/all of the following… –SQL –Query-by-Example –Query-by-Form

© 2002 by Prentice Hall 20 SQL Non-Procedural –Only define result Transform-Oriented SELECT Name, Age FROM PATIENT WHERE Physician = ‘Levy’

© 2002 by Prentice Hall 21 Query-by-Example

© 2002 by Prentice Hall 22 Query-by-Example Originally developed by IBM for mainframe (DB2) Ported down to PC (Paradox) No official standard, but widely used

© 2002 by Prentice Hall 23 Query by Form

© 2002 by Prentice Hall 24 DML Interfaces to DBMS Forms Query Language (i.e. SQL) Stored Procedures Application Program Interface

© 2002 by Prentice Hall 25 Stored Procedures Some DML tasks are performed on a routine or regular basis The DML procedure may be saved in the DBMS and recalled at a later date Note… the DML-code is saved, not the results of the query/update. As such, when the procedure is retrieved the results will be refreshed.

© 2002 by Prentice Hall 26 Stored Procedure Example CREATE PROCEDURE DELETECUSTOMER (MyCustomerID IN NUMBER) IS BEGIN Delete From Customer Where CustomerID = MyCustomerID; End DeleteCustomer;

© 2002 by Prentice Hall 27 Trigger Special type of stored procedure associated with a table When Trigger Condition for the table is met, Trigger Body is fired –Condition: Before, After Trigger Statement: Insert, Update, Delete

© 2002 by Prentice Hall 28 Trigger Example CREATE TRIGGER DeleteCustomer BEFORE DELETE ON Customer FOR EACH ROW BEGIN INSERT INTO CustomerHistory VALUES(CUSTOMERID, LastName, FirstName); END DeleteCustomer;

© 2002 by Prentice Hall 29 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 30 API Dynamic –Generates SQL code “on the fly” –ODBC: allows processing of many RDBMS with no program changes Embedded –SQL statements “hard coded” into application –Requires recompiling/linking

© 2002 by Prentice Hall 31 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 32 Relational Algebra Operators Relational algebra provides several operators: –Union –Difference –Intersection –Product –Projection –Selection –Join

© 2002 by Prentice Hall 33 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 34 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 35 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 36 Difference Operator JUNIOR relation HONOR- STUDENT relation JUNIOR minus HONOR- STUDENT relation

© 2002 by Prentice Hall 37 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 38 Intersection Operator JUNIOR relation HONOR- STUDENT relation Intersection of JUNIOR and HONOR- STUDENT relations

© 2002 by Prentice Hall 39 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 40 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 41 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 42 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 43 Data for Join Examples SIDNameMajorGradeLevel 123JonesHistoryJR 158ParksMathGR 271SmithHistoryJR 105AndersonManagementSN StudentNumberClassNamePositionNumber 123H BA B4907

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

© 2002 by Prentice Hall 45 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 46 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 47 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 48 Summary of Relational Algebra Operators

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