copyright © 2016 ramez elmasri and shamkant b. navathe · database system concepts and...

36
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe

Upload: others

Post on 21-Aug-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe

Page 2: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe

CHAPTER 2

Database System Concepts and Architecture

Slide 1- 2

Page 3: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 3

Outline

n Data Models and Their Categoriesn History of Data Modelsn Schemas, Instances, and Statesn Three-Schema Architecturen Data Independencen DBMS Languages and Interfacesn Database System Utilities and Toolsn Centralized and Client-Server Architecturesn Classification of DBMSs

Page 4: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 4

Data Models

n Data Model:n A set of concepts to describe the structure of a database,

the operations for manipulating these structures, and certain constraints that the database should obey.

n Data Model Structure and Constraints:n Constructs are used to define the database structuren Constructs typically include elements (and their data

types) as well as groups of elements (e.g. entity, record, table), and relationships among such groups

n Constraints specify some restrictions on valid data; these constraints must be enforced at all times

Page 5: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 5

Data Models (continued)

n Data Model Operations:n These operations are used for specifying database

retrievals and updates by referring to the constructs of the data model.

n Operations on the data model may include basic model operations (e.g. generic insert, delete, update) and user-defined operations (e.g. compute_student_gpa, update_inventory)

Page 6: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 6

Categories of Data Modelsn Conceptual (high-level, semantic) data models:

n Provide concepts that are close to the way many users perceive data.

n (Also called entity-based or object-based data models.)n Physical (low-level, internal) data models:

n Provide concepts that describe details of how data is stored in the computer. These are usually specified in an ad-hoc manner through DBMS design and administration manuals

n Implementation (representational) data models:n Provide concepts that fall between the above two, used by

many commercial DBMS implementations (e.g. relational data models used in many commercial systems).

n Self-Describing Data Models:n Combine the description of data with the data values.

Examples include XML, key-value stores and some NOSQL systems.

Page 7: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 7

Schemas versus Instances

n Database Schema:n The description of a database.n Includes descriptions of the database structure,

data types, and the constraints on the database.n Schema Diagram:

n An illustrative display of (most aspects of) a database schema.

n Schema Construct:n A component of the schema or an object within

the schema, e.g., STUDENT, COURSE.

Page 8: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 8

Schemas versus Instances

n Database State:n The actual data stored in a database at a

particular moment in time. This includes the collection of all the data in the database.

n Also called database instance (or occurrence or snapshot).

n The term instance is also applied to individual database components, e.g. record instance, table instance, entity instance

Page 9: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 9

Database Schema vs. Database State

n Database State: n Refers to the content of a database at a moment

in time.n Initial Database State:

n Refers to the database state when it is initially loaded into the system.

n Valid State:n A state that satisfies the structure and constraints

of the database.

Page 10: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 10

Database Schema vs. Database State (continued)

n Distinctionn The database schema changes very infrequently. n The database state changes every time the

database is updated.

n Schema is also called intension.n State is also called extension.

Page 11: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 11

Example of a Database Schema

Page 12: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 12

Example of a database state

Page 13: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 13

Three-Schema Architecture

n Proposed to support DBMS characteristics of:n Program-data independence.n Support of multiple views of the data.

n Not explicitly used in commercial DBMS products, but has been useful in explaining database system organization

Page 14: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 14

Three-Schema Architecture

n Defines DBMS schemas at three levels:n Internal schema at the internal level to describe physical

storage structures and access paths (e.g indexes). n Typically uses a physical data model.

n Conceptual schema at the conceptual level to describe the structure and constraints for the whole database for a community of users.

n Uses a conceptual or an implementation data model.n External schemas at the external level to describe the

various user views. n Usually uses the same data model as the conceptual schema.

Page 15: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 15

The three-schema architecture

Page 16: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 16

Three-Schema Architecture

n Mappings among schema levels are needed to transform requests and data. n Programs refer to an external schema, and are

mapped by the DBMS to the internal schema for execution.

n Data extracted from the internal DBMS level is reformatted to match the user’s external view (e.g. formatting the results of an SQL query for display in a Web page)

Page 17: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 17

Data Independence

n Logical Data Independence: n The capacity to change the conceptual schema

without having to change the external schemas and their associated application programs.

n Physical Data Independence:n The capacity to change the internal schema

without having to change the conceptual schema.n For example, the internal schema may be changed

when certain file structures are reorganized or new indexes are created to improve database performance

Page 18: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 18

Data Independence (continued)

n When a schema at a lower level is changed, only the mappings between this schema and higher-level schemas need to be changed in a DBMS that fully supports data independence.

n The higher-level schemas themselves are unchanged.n Hence, the application programs need not be

changed since they refer to the external schemas.

Page 19: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 19

DBMS Languages

n Data Definition Language (DDL)n Data Manipulation Language (DML)

n High-Level or Non-procedural Languages: These include the relational language SQL

n May be used in a standalone way or may be embedded in a programming language

n Low Level or Procedural Languages:n These must be embedded in a programming

language

Page 20: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 20

DBMS Languages

n Data Definition Language (DDL): n Used by the DBA and database designers to

specify the conceptual schema of a database.n In many DBMSs, the DDL is also used to define

internal and external schemas (views).n In some DBMSs, separate storage definition

language (SDL) and view definition language (VDL) are used to define internal and external schemas.

n SDL is typically realized via DBMS commands provided to the DBA and database designers

Page 21: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 21

DBMS Languages

n Data Manipulation Language (DML):n Used to specify database retrievals and updatesn DML commands (data sublanguage) can be

embedded in a general-purpose programming language (host language), such as COBOL, C, C++, or Java.

n A library of functions can also be provided to access the DBMS from a programming language

n Alternatively, stand-alone DML commands can be applied directly (called a query language).

Page 22: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 22

Types of DML

n High Level or Non-procedural Language:n For example, the SQL relational languagen Are “set”-oriented and specify what data to retrieve

rather than how to retrieve it. n Also called declarative languages.

n Low Level or Procedural Language:n Retrieve data one record-at-a-time; n Constructs such as looping are needed to retrieve

multiple records, along with positioning pointers.

Example :

Page 23: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 23

DBMS Interfaces

n Stand-alone query language interfacesn Example: Entering SQL queries at the DBMS

interactive SQL interface (e.g. SQL*Plus in ORACLE)

n Programmer interfaces for embedding DML in programming languages

n User-friendly interfacesn Menu-based, forms-based, graphics-based, etc.

n Mobile Interfaces:interfaces allowing users to perform transactions using mobile apps

Page 24: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 24

DBMS Programming Language Interfaces

n Programmer interfaces for embedding DML in a programming languages:n Embedded Approach: e.g embedded SQL (for C, C++, etc.),

SQLJ (for Java)n Procedure Call Approach: e.g. JDBC for Java, ODBC (Open

Databse Connectivity) for other programming languages as API’s (application programming interfaces)

n Database Programming Language Approach: e.g. ORACLE has PL/SQL, a programming language based on SQL; language incorporates SQL and its data types as integral components

n Scripting Languages: PHP (client-side scripting) and Python (server-side scripting) are used to write database programs.

What ? This author has no idea what PHP is ! !

Page 25: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 25

User-Friendly DBMS Interfaces

n Menu-based (Web-based), popular for browsing on the web

n Forms-based, designed for naïve users used to filling in entries on a form

n Graphics-based n Point and Click, Drag and Drop, etc.n Specifying a query on a schema diagram

n Natural language: requests in written Englishn Combinations of the above:

n For example, both menus and forms used extensively in Web database interfaces

Page 26: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 26

Other DBMS Interfaces

n Natural language: free text as a queryn Speech : Input query and Output responsen Web Browser with keyword searchn Parametric interfaces, e.g., bank tellers using

function keys.n Interfaces for the DBA:

n Creating user accounts, granting authorizationsn Setting system parametersn Changing schemas or access paths

Page 27: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 27

Database System Utilities

n To perform certain functions such as:n Loading data stored in files into a database.

Includes data conversion tools.n Backing up the database periodically on tape.n Reorganizing database file structures.n Performance monitoring utilities.n Report generation utilities.n Other functions, such as sorting, user monitoring,

data compression, etc.

Page 28: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 30

Typical DBMS Component Modules

Page 29: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 37

Two Tier Client-Server Architecture

n Client and server must install appropriate client module and server module software for ODBC or JDBC

n A client program may connect to several DBMSs, sometimes called the data sources.

n In general, data sources can be files or other non-DBMS software that manages data.

n See Chapter 10 for details on Database Programming

Page 30: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 38

Three Tier Client-Server Architecturen Common for Web applicationsn Intermediate Layer called Application Server or Web

Server: n Stores the web connectivity software and the business logic

part of the application used to access the corresponding data from the database server

n Acts like a conduit for sending partially processed data between the database server and the client.

n Three-tier Architecture Can Enhance Security: n Database server only accessible via middle tiern Clients cannot directly access database servern Clients contain user interfaces and Web browsersn The client is typically a PC or a mobile device connected to

the Web

Page 31: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 39

Three-tier client-server architecture

Page 32: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 40

Classification of DBMSsn Based on the data model used

n Legacy: Network, Hierarchical.n Currently Used: Relational, Object-oriented, Object-

relationaln Recent Technologies: Key-value storage systems,

NOSQL systems: document based, column-based, graph-based and key-value based. Native XML DBMSs.

n Other classificationsn Single-user (typically used with personal computers)

vs. multi-user (most DBMSs).n Centralized (uses a single computer with one

database) vs. distributed (multiple computers, multiple DBs)

F

Page 33: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 41

Variations of Distributed DBMSs (DDBMSs)

n Homogeneous DDBMSn Heterogeneous DDBMSn Federated or Multidatabase Systems

n Participating Databases are loosely coupled with high degree of autonomy.

n Distributed Database Systems have now come to be known as client-server based database systems because:n They do not support a totally distributed

environment, but rather a set of database servers supporting a set of clients.

Page 34: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 42

Cost considerations for DBMSsn Cost Range: from free open-source systems to

configurations costing millions of dollarsn Examples of free relational DBMSs: MySQL, PostgreSQL,

othersn Commercial DBMS offer additional specialized modules,

e.g. time-series module, spatial data module, document module, XML modulen These offer additional specialized functionality when

purchased separatelyn Sometimes called cartridges (e.g., in Oracle) or blades

n Different licensing options: site license, maximum number of concurrent users (seat license), single user, etc.

Page 35: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe

Other Considerations

n Type of access paths within database systemn E.g.- inverted indexing based (ADABAS is one

such system).Fully indexed databases provide access by any keyword (used in search engines)

n General Purpose vs. Special Purposen E.g.- Airline Reservation systems or many others-

reservation systems for hotel/car etc. Are special purpose OLTP (Online Transaction Processing Systems)

Slide 2- 43

Page 36: Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe · Database System Concepts and Architecture Slide 1-2. ... structure and constraints for the whole database for a community

Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe Slide 2- 53

Chapter Summary

n Data Models and Their Categoriesn Schemas, Instances, and Statesn Three-Schema Architecturen Data Independencen DBMS Languages and Interfacesn Database System Utilities and Toolsn Database System Environmentn Centralized and Client-Server Architecturesn Classification of DBMSsn History of Data Models-