Chapter 3 An Introduction to Relational Databases.

Slides:



Advertisements
Similar presentations
Relational Database and Data Modeling
Advertisements

Introduction to Relational Database Systems 1 Lecture 4.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
The Relational Model and Relational Algebra Nothing is so practical as a good theory Kurt Lewin, 1945.
Chapter 3 An Introduction to Relational Databases.
D ATABASE S YSTEMS I A DMIN S TUFF. 2 Mid-term exam Tuesday, Oct 2:30pm Room 3005 (usual room) Closed book No cheating, blah blah No class on Oct.
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.
Database management concepts Database Management Systems (DBMS) An example of a database (relational) Database schema (e.g. relational) Data independence.
Chapter 3 An Introduction to Relational Databases.
11 3 / 12 CHAPTER Databases MIS105 Lec14 Irfan Ahmed Ilyas.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education, Inc. publishing as Prentice Hall 4-1.
Chapter 1 An Overview of Database Management. 1-2 Topics in this Chapter What is a Database System? What is a Database? Why Database? Data Independence.
Mgt 20600: IT Management & Applications Databases Tuesday April 4, 2006.
Chapter 4 Relational Databases Copyright © 2012 Pearson Education 4-1.
An Introduction to Database Management Systems R. Nakatsu.
Chapter 6 Relations. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.6-2 Topics in this Chapter Tuples Relation Types Relation Values Relation.
Introduction To Databases IDIA 618 Fall 2014 Bridget M. Blodgett.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Irwin/McGraw-Hill Copyright © 2000 The McGraw-Hill Companies. All Rights reserved Whitten Bentley DittmanSYSTEMS ANALYSIS AND DESIGN METHODS5th Edition.
Module Title? DBMS E-R Model to Relational Model.
Project Implementation for COSC 5050 Distributed Database Applications Lab2.
Introduction –All information systems create, read, update and delete data. This data is stored in files and databases. Files are collections of similar.
Chapter 3 An Introduction to Relational Databases.
STORING ORGANIZATIONAL INFORMATION— DATABASES CIS 429—Chapter 7.
Chapter 9 Integrity. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.9-2 Topics in this Chapter Predicates and Propositions Internal vs.
CODD’s 12 RULES OF RELATIONAL DATABASE
Page 1 Topic 4 Relational Databases CPS510 Database Systems Abdolreza Abhari School of Computer Science Ryerson University.
DBSQL 3-1 Copyright © Genetic Computer School 2009 Chapter 3 Relational Database Model.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
GUS: 0262 Fundamentals of GIS Lecture Presentation 3: Relational Data Model Jeremy Mennis Department of Geography and Urban Studies Temple University.
Lecture2: Database Environment Prepared by L. Nouf Almujally & Aisha AlArfaj 1 Ref. Chapter2 College of Computer and Information Sciences - Information.
An Introduction to Relational Databases Prof. Yin-Fu Huang CSIE, NYUST Chapter 3.
1.1 CAS CS 460/660 Relational Model. 1.2 Review E/R Model: Entities, relationships, attributes Cardinalities: 1:1, 1:n, m:1, m:n Keys: superkeys, candidate.
5-1 McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved.
Lecture2: Database Environment Prepared by L. Nouf Almujally 1 Ref. Chapter2 Lecture2.
CHAPTER 3 DATABASES AND DATA WAREHOUSES. 2 OPENING CASE STUDY Chrysler Spins a Competitive Advantage with Supply Chain Management Software Chapter 2 –
6.1 © 2010 by Prentice Hall 6 Chapter Foundations of Business Intelligence: Databases and Information Management.
Prepared By Prepared By : VINAY ALEXANDER ( विनय अलेक्सजेंड़र ) PGT(CS),KV JHAGRAKHAND.
Chapter 9 Database Systems Introduction to CS 1 st Semester, 2014 Sanghyun Park.
Chapter 5 Types. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.5-2 Topics in this Chapter Values vs. Variables Types vs. Representations.
Chapter 3 Databases and Data Warehouses: Building Business Intelligence Copyright © 2010 by the McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin.
Chapter 9 Database Systems © 2007 Pearson Addison-Wesley. All rights reserved.
Chapter 9 Database Systems. © 2005 Pearson Addison-Wesley. All rights reserved 9-2 Chapter 9: Database Systems 9.1 Database Fundamentals 9.2 The Relational.
Chapter 16 Concurrency. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.16-2 Topics in this Chapter Three Concurrency Problems Locking Deadlock.
GLOBEX INFOTEK Copyright © 2013 Dr. Emelda Ntinglet-DavisSYSTEMS ANALYSIS AND DESIGN METHODSINTRODUCTORY SESSION EFFECTIVE DATABASE DESIGN for BEGINNERS.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
The relational model A data model (in general) : Integrated collection of concepts for describing data (data requirements). Relational model was introduced.
Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin APPENDIX C DESIGNING DATABASES APPENDIX C DESIGNING DATABASES.
Principles of Database Design, Part I AIMS 2710 R. Nakatsu.
Chapter 10 Views. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.10-2 Topics in this Chapter What are Views For? View Retrievals View Updates.
Databases Flat Files & Relational Databases. Learning Objectives Describe flat files and databases. Explain the advantages that using a relational database.
ASET 1 Amity School of Engineering & Technology B. Tech. (CSE/IT), III Semester Database Management Systems Jitendra Rajpurohit.
1 CS 430 Database Theory Winter 2005 Lecture 7: Designing a Database Logical Level.
Chapter 1: Introduction. 1.2 Database Management System (DBMS) DBMS contains information about a particular enterprise Collection of interrelated data.
LECTURE TWO Introduction to Databases: Data models Relational database concepts Introduction to DDL & DML.
Chapter 4 An Introduction to SQL. Copyright © 2004 Pearson Addison-Wesley. All rights reserved.4-2 Topics in this Chapter SQL: History and Overview The.
1 Section 1 - Introduction to SQL u SQL is an abbreviation for Structured Query Language. u It is generally pronounced “Sequel” u SQL is a unified language.
Chapter 2 The Big Picture. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 2-2 Databases We are particularly interested in relational databases.
 2012 Pearson Education, Inc. All rights reserved.
STRUCTURE OF PRESENTATION :
Chapter 9 Database Systems
Lecture 2 The Relational Model
Chapter 4 Relational Databases
STRUCTURE OF PRESENTATION :
Translation of ER-diagram into Relational Schema
Chapter 3 The Relational Database Model
Database Design: Relational Model
Presentation transcript:

Chapter 3 An Introduction to Relational Databases

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-2 Topics in this Chapter The Relational Model Relations and Relvars What Relations Mean Optimization The Catalog Base Relvars and Views Transactions

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-3 The Relational Model – Informally Structural –Data is perceived by users as tables Integrity –Data subject to specific integrity requirements Manipulation –Operators derive tables from other tables Restrict Project Join

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-4 The Relational Model – Operators, Informally Restrict –Extracts specified rows (a/k/a “Select”) Project –Extracts specified columns Join –Combines two tables into one –Based on common values in common column

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-5 Fig.3.1 The departments-and-employees database (sample values) Fig.3.2 Restrict, project, and join (examples)

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-6 The Relational Model – Materialization, and Set Processing, Informally Materialized evaluation of operators –Generates tables for all steps Pipelined evaluation of operators –Piecemeal intermediate steps Relational operators are set operators –No “row at a time” processing

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-7 The Relational Model – Logical/Physical, Informally Data is perceived by the user as tables DBMS can store the data on disk in other formats –Sequential files, indexes, pointer chains, hashing The Information Principle: Information represented by rows and columns, only No user-detected pointers Tables are joined logically based on user understood column values

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-8 The Relational Model – Integrity, Informally Every table has a “primary key” –Column whose value implies values in the other columns Some tables have a “foreign key” –References primary key of another table –Used to maintain links between tables –Column whose value implies values in columns in another table

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-9 The Relational Model – More Formally An open-ended collection of scalar types A relation type generator Facilities to define relation variables in generated types A relation assignment operator to assign values to relation variables An open-ended set of relational operators used to derive relation values from other relation values

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-10 Relations Relation is a mathematical term A table is a relation, mathematically speaking Codd was the first to promulgate this Relations have tuples or rows, not records And attributes or columns, not fields In Codd we trust

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-11 Relations and Relvars Relation is a mathematical term A relation is inherently a specific set of values A relation variable, or relvar, is the structure into which values are set Relvars can have different values at different times Most writers use “relation” (or “table’) to mean both the structure and the instantiated values But not from this Date forward DELETE EMP WHERE EMP# = EMP#(‘E4’); EMP := EMP WHERE NOT (EMP# = EMP#(‘E4’)); Fig.3.3 Relation variable EMP after deleting E4 row

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-12 Formally, What Relations Mean: Relations vs. Types Relational model includes an open-ended set of types i.e. users can define their own types A type can be regarded as the set of all its possible instances e.g. Emp# as a type is the set of all possible employee numbers

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-13 Formally, What Relations Mean: Types and their Predicates Every relation – that is to say – every relation value – is divided into two – head and body Head has name and type for the column Body has rows that conform to the head e.g. Emp# is the name of the column, and could also be its type, if we have defined such a type; otherwise the type could be NUM Fig.3.4 Sample EMP relation value, showing column types

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-14 Formally, What Relations Mean: Types and their Predicates, continued For any relation, the head denotes a predicate A predicate is a truth-valued function that can take (as any function can) parameters For any relation, each row of the body denotes a true proposition A true proposition is obtained from the predicate by instantiating it (sending in arguments in place of the parameters)

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-15 Formally, What Relations Mean: Types and their Predicates, continued Predicate example: –Employee EMP# is named ENAME, works in department DEPT#, and earns salary SALARY –EMP#, ENAME, DEPT#, and SALARY are parameters as well as table column headings True proposition example: –Employee E1 is named Lopez, works in department D1, and earns salary 40k –E1, Lopez, D1, and 40k are arguments as well as table atomic values

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-16 Formally, What Relations Mean: Types and their Predicates, continued Types are sets of things we can talk about Relations are sets of things we say about the things we can talk about A relvar is a predicate A relation is a set of true propositions

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-17 Optimization Relational operators are set operators Relational languages are less procedural than procedural languages Relational languages function at a higher level of abstraction than do procedural languages Relational Database Management implementations require an optimizer Optimizer handles the “how” after the user specifies the “what result”

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-18 Fig.3.5 Automatic vs. manual navigation

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-19 The Catalog System catalog is required to keep track of all database objects Can be thought of as a dictionary Implemented in relvars (known to the DBMS as tables) that can be queried ex) - (COLUMN WHERE TABNAME = ‘DEPT’) { COLNAME } - (COLUMN WHERE COLNAME = ‘EMP#’) {TABNAME} - ((TABLE JOIN COLUMN) WHERE COLCOUNT < 5) {TABNAME, COLNAME}

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-20 Fig.3.6 Catalog for the departments-and-employees database (in outline)

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-21 Base Relvars and Views Base relvars –Created in SQL via CREATE TABLE Views can be derived from base relvars –Created in SQL via CREATE VIEW View relvars are stored in the catalog View values do not exist separately View values are whatever populates the base relation at the time the user queries the view The user perceives the view as a real relation

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-22 CREATE VIEW TOPEMP AS (EMP WHERE SALARY > 33K) {EMP#, ENAME, SALARY}; (TOPEMP WHERE SALARY < 42K) {EMP#, SALARY } Fig.3.7 TOPEMP as a view of EMP (unshaded portions)

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-23 Transactions A transaction is a logical unit of work May encompass one or many operations –SQL uses BEGIN TRANSACTION, COMMIT, and ROLLBACK to support transactions Transactions are atomic, durable, isolated, and serializable More detail on this to come (ch 15-16) ex) BEGIN TRANSACTION; UPDATE account A = A – 10; UPDATE account B = B + 10; IF everything worked fine THEN COMMIT; ELSEROLLBACK; END IF;

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-24 Suppliers-and-parts Database Fig.3.8 The suppliers-and-parts database (sample values)

Copyright © 2004 Pearson Addison-Wesley. All rights reserved.3-25 Fig.3.9 The suppliers-and-parts database (data definition)