Introduction to Database Systems Part II

Slides:



Advertisements
Similar presentations
Database System Concepts and Architecture
Advertisements

Chapter 2 Database System Concepts and Architecture
ICS (072)Database Systems Background Review 1 Database Systems Background Review Dr. Muhammad Shafique.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Overview of Database Languages and Architectures.
Database System Concepts and Architecture Dr. Ali Obaidi.
1 Chapter 2 Database Environment. 2 Chapter 2 - Objectives u Purpose of three-level database architecture. u Contents of external, conceptual, and internal.
Chapter One Overview of Database Objectives: -Introduction -DBMS architecture -Definitions -Data models -DB lifecycle.
Database System Concepts and Architecture Lecture # 3 22 June 2012 National University of Computer and Emerging Sciences.
Information storage: Introduction of database 10/7/2004 Xiangming Mu.
Chapter 2 CIS Sungchul Hong
Database System Concepts and Architecture
Introduction to Database Systems
2. Database System Concepts and Architecture
1 CS 430 Database Theory Winter 2005 Lecture 2: General Concepts.
Database Environment Chapter 2. Data Independence Sometimes the way data are physically organized depends on the requirements of the application. Result:
1Mr.Mohammed Abu Roqyah. Database System Concepts and Architecture 2Mr.Mohammed Abu Roqyah.
DATABASE MANAGEMENT SYSTEM ARCHITECTURE
DataBase System Concepts and Architecture
1 Chapter 2 Database Environment Pearson Education © 2009.
Postgraduate Module Enterprise Database Systems Technological Educational Institution of Larisa in collaboration with Staffordshire University Larisa
1 Database Design Chapter-2- Database System Concepts and Architecture Reference: Prof. Mona Mursi Lecture notes.
Introduction: Databases and Database Systems Lecture # 1 June 19,2012 National University of Computer and Emerging Sciences.
Databases and Database User ch1 Define Database? A database is a collection of related data.1 By data, we mean known facts that can be recorded and that.
Fundamental of Database Systems
College of Arts & Science Computer Science Department
Chapter (2) Database Systems Concepts and Architecture Objectives
Introduction to DBMS Purpose of Database Systems View of Data
Databases (CS507) CHAPTER 2.
Databases and DBMSs Todd S. Bacastow January 2005.
國立臺北科技大學 課程:資料庫系統 Chapter 2 Database Environment.
CS4222 Principles of Database System
REV 00 Chapter 2 Database Environment DDC DATABASE SYSTEM.
Introduction to Databases
Plan for Intro to DB Systems I
REV 00 Chapter 2 Database Environment DDC DATABASE SYSTEM.
Database Management.
Chapter 2: Database System Concepts and Architecture - Outline
Chapter (2) Database Systems Concepts and Architecture Objectives
Chapter 2 Database Environment.
Chapter 2 Database System Concepts and Architecture
Chapter 1: Introduction
Introduction What is a Database?.
Database System Concepts and Architecture
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 2 Database System Concepts and Architecture.
Introduction to Databases
Introduction to Databases
Chapter 2 Database Environment.
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 2: Database System Concepts and Architecture
Introduction to Database Management System
Introduction to Database Systems
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 2 Database Environment.
Data Base System Lecture : Database Environment
Data, Databases, and DBMSs
Data Base System Lecture 2: Introduction to Database
Database Environment Transparencies
Database Systems Instructor Name: Lecture-3.
Introduction to DBMS Purpose of Database Systems View of Data
Introduction to Databases
Chapter 1: Introduction
UNIT-I Introduction to Database Management Systems
Chapter 2 Database Environment Pearson Education © 2014.
Chapter 1: Introduction
Chapter 1: Introduction
Chapter 1: Introduction
Database System Concepts and Architecture
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 2 Database Environment Pearson Education © 2009.
Chapter 1: Introduction
Presentation transcript:

Introduction to Database Systems Part II Coordinator: Dr Hui Ma Lecturer: Dr Pavle Mogin

Plan for Intro to DB Systems II Data models Structural component Dynamic component Data manipulation languages Navigational Declarative Schemas and Instances The Three Schema Architecture Program - Data Independence Reading: Chapter 2 of the textbook

Data Models A Data Model: a set of concepts to describe the structure and constraints of a database, and the operations for manipulating these structures Also, a data model is said to be a mathematical abstraction that is used: To make an approximate representation (an abstraction) of a real system, and To make a model of a database of the real system A data model provides components to represent: The structure (and constraints), and Dynamics of a real system and to map them to a database structure, constraints, and operations People also say that a data model is a language, or formalism to describe a database

Data Models – Structural Component The structural component contains primitive concepts, and rules to combine them into more complex concepts Example: Use data that describe some properties of an entity to build the model of the entity itself (Surname: Bond, Name: James, StudentId: 007007, Major: Comp) (Integrity) constraints are statements about values and relationships that must hold between data Examples: Each student must have unique StudId, NoofPts is a nonnegative integer, less than 1000, For any course, a student can get at most one grade in a term Data are primitive concepts, instruction: put … together is a rule to combine primitive concepts

Structural Component (continued) Abstract representation at the level of properties Part of the real world Student StId Name Surname Pts Constraint: StId values are unique

Dynamic Component - Operations Dynamic aspects of a real world system (UoD) are modeled using: Basic operations (database retrieval and update), and Complex operations (complex logic, GUI) These operations are supported by programming languages: A data manipulation language (retrieval and updates), and A general purpose programming language (complex logic and GUI) Complex logic – many conditional statements

Data Manipulation Language (DML) Used to retrieve, insert, delete, and modify data In the real world, entities are created (insert), used (retrieve) and altered (update), and finally they expire (delete) Always selects a relatively small part of a database and transfers it from disk to main memory A DML can be: Either navigational, or Declarative

Navigational DML Procedural (has loops, branching conditions), Selects a record at a time, Programmer explicitly utilizes information about database physical organization to “navigate” through the database, Programmer defines WHAT and HOW

Declarative DML Non procedural, Set oriented (selects all data that match given conditions), Search conditions are defined according to an abstract database representation, so the programs are completely independent of a database physical organization, A programmer (or even a casual user) has to define just WHAT

Navigational versus Declarative DML (1) Query: “Retrieve all Courses and Grades of the student with StudentId = 131313” Simplified navigational pseudo code: Find the student record with StudentId = 131313 in GRADES If successful then Do while there are courses connected to the student Find next course Id in GRADES Find corresponding Grade Find corresponding Course name in COURSE End do Else Display error message End if

Navigational versus Declarative DML (2) Query: “Retrieve all Courses and grades of the student with StudentId = 131313” A fully declarative program: SELECT Course_id, Cname, Grade FROM COURSE C, GRADES G WHERE StudentId = 131313 AND G.CourseId = C.CourseId;

Database Users and Languages Database administrator (DBA) and DB designer: Data Definition Language (DDL) to describe conceptual (or implementation) schema, View Definition Language (VDL) to describe user views Storage Definition Language (SDL) to describe internal schema Casual end users: Interactive declarative DML – mainly for database queries Naïve (or parametric) users: Canned transaction programs (written by programmers) Programmers: Interactive DML, DML embedded into general purpose (host) programming language

Classification of Data Models High level (conceptual) data models: Enhanced Entity Relationship (EER - highly abstract, no DBMS), Higher level implementation data models: Object-oriented (some DBMS, mainly navigational), used as a conceptual data model in the software engineering Representational (Implementation) data models network (legacy, navigational), hierarchical (legacy, navigational), relational (contemporary DBMS mainly implemented on it, declarative), Low level (physical storage) data models ISAM, VSAM (file systems)

Schemas and Instances A schema is a model of a real system, and an abstract description of it’s database A database schema bears information about database structure and constraints A database schema is a fairly static category An object of a database schema (as Student ) is sometimes called schema construct A database schema is designed and then defined to a DBMS using a Data Definition Language

An ER and a Relational Database Schema ER Schema Major Points Department Exam N M Student Course LName FName StudID Grade CName CourseId Relational Schema STUDENT (StudentId, LName, FName, Major), GRADES (StudentId, CourseId, Grade), COURSE (CName, CourseId, Points, Department)

Schemas and Instances (continued) A database state or a schema instance (often referred to as a database) is a collection of related data that mirror one of the possible states of a real system A schema instance: Is produced by populating (loading) schema description by data Corresponds to schema structure, and Satisfies all schema constraints A schema instance should reflect changes of the real system’s state, and that is accomplished by its updating (a schema instance is a dynamic category) Often, schemas are referred to as intensions and instances are referred to as extensions We view the intension as a set of integrity constraints (i.e. conditions that define all of the allowable extensions).

A Database Instance Student LName FName StudId Smith Susan 131313 Bond James 007007 555555 Grade StudId CourseId 007007 C302 A+ C301 A M214 131313 B- 555555 C D E Course CName CourseId DB Sys C302 SofEng C301 DisMat M214 This is just a graphical representation of a part of a database. The real database would be stored on an computer memory device, by means of binary symbols. But neglecting this, that set of interrelated tables with data: represents an UoD, is well structured, can reflect changes, and we can imagine possible users and applications. So we shall consider it as a possible representation of a database.

Data Organization Approaches There are two characteristic approaches to data organization and storage in the realm of an information system These are: File approach (traditional), and Database approach. Both approaches start from the supposition that UoD functions (like HR, Acc, Sales, Payroll,…) are supported by an application, containing a number of programs According to the traditional approach, each application contains all necessary data, as its own, organized into files If two applications need the same data, files may be duplicated Duplication leads to data redundancy and inconsistency If files are not duplicated, then the two applications suffer from access concurrency and may have different data access mode needs In the database approach all applications use a common database (no application owns the database)

Data base DBMS Database Approach Application #1 Application #2 A single repository, used by all application programs – no data redundancy, and more important - no data collision A catalog – data dictionary with conceptual data representation Application #3 Application #n

Data Independence In the traditional (file) approach to data organization, information about a file’s physical structure was embedded into programs The same was true for the first (pre-relational) database systems Changes of the file structure induced changes in programs This phenomenon was called (program -) data dependence The use of declarative manipulation languages relived databases from the program-data dependence

The Three Schema Architecture ANSI/SPARK 1975 Three levels of schema definition (as design categories): External (user view – often EER data model, can also be relational), Conceptual (global view – often EER data model, can also be relational), and Internal (database physical structure – indexes, hashing algorithms, pointers, disk extents,…) If the conceptual schema is defined in the EER data model, then we should also talk about implementation (relational) level

Physical Data Independence Lect3: Introduction DB(2) SWEN304 Physical Data Independence Means: The physical organization of the data is almost independent from the conceptual / logical organization Changes to physical schema have no implications on the logical / conceptual layer Allow to abstract from the realization of the DBMS storage organization Allow to reason about data without worrying about the physical realization Allow physical optimization / tuning Achieved through conceptual to physical schema mapping performed by DBMS

Physical Data Independence Independence: achieved by DBMS mapping conceptual to physical schema C O N S C C E H P E T M U A A L Program #1 Program #2 Data Base DBMS The conceptual database schema description is embedded in every program. Since the conceptual schema doesn’t have information about physical database structure, that way is physical data independence achieved. DBMS accepts program requests made against conceptual schema concepts, and maps them to actual database physical structure. But the whole conceptual schema may be very large, and can change relatively frequently. Every change requires changing of all programs. (Although these changes are less complex than the changes induced by the physical structure, because they influence only declarative part of the program.) Program #n

Logical Data Independence Means: the external presentation and manipulation of the data is almost independent from the conceptual/logical organization Changes to the conceptual/logical schema should not affect the external schema Only mapping shall be changed An application program should only see the external schema View update problem is solved using virtual views

Logical Data Independence ) Logical Data Independence Logical Independence Physical Independence Program #1 Program #2 External View #1 C O N S C C E H P E T M U A A L DBMS External View #2 Data Base Program #3 DBMS DBMS Every program uses a relatively small part of a conceptual schema. Instead of embedding conceptual schema into programs, only corresponding external schema should be included. So programs express their requests against the database in terms of external view concepts. DBMS translates these requests in to requests against conceptual schema concepts. Further, requests are translated into requests against internal schema, fetched from the database, and after inverse translations, placed into User Working Area (UWA) of the program. External View #3 Program #4 DBMS

Summary A data model is a (mathematical) abstraction that has structural and dynamic components The structural component is used to represent UoD structure and rules of behavior (constraints between data and relationships) Operations are used to model dynamics of a UoD The representation of a UoD by structure and operations constitutes a database design Database schema – abstract description of a UoD structure and rules of behavior A schema instance – an image of a UoD state – the database itself Main advantages of the database over traditional approach: Program – data independence, Data consistency monitored by a DBMS, DBMS controlled data sharing and recovery

Plan for the Next Lecture Introduction to the relational data model – motives and basic ideas Basic terms and concepts of the relational data model Relational schemas and instances Constraints of the relational data model Reading Chapter 5 of the textbook sections 5.1 and 5.2