Chapter 2 Database System Concepts and Architecture PDF

Document Details

CleverSaxophone

Uploaded by CleverSaxophone

An-Najah National University

2007

Ramez Elmasri and Shamkant B. Navathe

Tags

database systems database concepts database architecture computer science

Summary

This document is about database system concepts and architecture. It details different data models like conceptual, physical, and implementation models. It also discusses schema and instances in a database context using the ERD.

Full Transcript

Chapter 2 Database System Concepts and Architecture Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Outline Data Models and Their Categories History of Data Models Schemas, Instances, and States Three-Schema Architecture Data Independence DBMS Languages and Interfaces...

Chapter 2 Database System Concepts and Architecture Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Outline Data Models and Their Categories History of Data Models Schemas, Instances, and States Three-Schema Architecture Data Independence DBMS Languages and Interfaces Database System Utilities and Tools Centralized and Client-Server Architectures Classification of DBMSs Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 2 Data Models Data Model: A set of concepts to describe the structure of a database, structure includes: data types, relationships and constraints that should hold. Data Model Operations: Data model includes a set of basic operations for specifying retrievals and update on the database, in addition to user- defined operations (e.g. compute_student_gpa, update_inventory) Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 3 Categories of Data Models Conceptual (high-level, semantic) data models: Provide concepts that are close to the way many users perceive data. (Also called entity-based or object-based data models.) Physical (low-level, internal) data models: 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 Implementation (representational) data models: Provide concepts that fall between the above two, used by many commercial DBMS implementations (e.g. relational data models used in many commercial systems). Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 4 Schemas versus Instances Database Schema: The description of a database. Includes descriptions of the database structure, data types, and the constraints on the database. Schema Diagram: An illustrative display of (most aspects of) a database schema. Schema Construct: A component of the schema or an object within the schema, e.g., STUDENT, COURSE. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 5 Example of a Database Schema Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 6 Schemas versus Instances Database State: The actual data stored in a database at a particular moment in time. This includes the collection of all the data in the database. Also called set of database instances or occurrences in the database, For example students construct will contain set of individuals student entities (records) as its instances. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 7 Example of a database state Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 8 Database Schema vs. Database State Every time we insert or delete a record or change the value of data item, we change the state of the database from one state to another. Initial Database State: Refers to the database state when it is initially loaded into the system. Valid State: A state that satisfies the structure and constraints of the database. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 9 Database Schema vs. Database State (continued) Distinction The database schema changes very infrequently. The database state changes every time the database is updated. Schema is also called intension. State is also called extension. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 10 Three-Schema Architecture Proposed to support DBMS characteristics of: Program-data independence. Support of multiple views of the data. use of a catalog to store the database description (schema). Not explicitly used in commercial DBMS products, but has been useful in explaining database system organization Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 11 Three-Schema Architecture Defines DBMS schemas at three levels: Internal schema at the internal level to describe physical storage structures and access paths (e.g indexes). Typically uses a physical data model. Conceptual schema at the conceptual level to describe the structure and constraints for the whole database for a community of users. Uses a conceptual or an implementation data model. External schemas at the external level to describe the various user views. Usually uses the same data model as the conceptual schema. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 12 The three-schema architecture Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 13 Differences among Levels External FacultyAssignmentFormView: data required for the form in Slide 16 FacultyWorkLoadReportView: data required for the report in Slide 17 Conceptual: tables in next Slide(slide 15) Internal Files needed to store the tables Extra files to improve performance Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 14 University Database Relationships Tables s Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 15 Sample Data Entry Form Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 16 Sample Report Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 17 Three-Schema Architecture Mappings among schema levels are needed to transform requests and data. Programs refer to an external schema, and are mapped by the DBMS to the internal schema for execution. 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) Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 18 Data Independence Logical Data Independence: The capacity to change the conceptual schema without having to change the external schemas and their associated application programs. Physical Data Independence: The capacity to change the internal schema without having to change the conceptual schema. For example, the internal schema may be changed when certain file structures are reorganized or new indexes are created to improve database performance Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 19 Data Independence (continued) 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. The higher-level schemas themselves are unchanged. Hence, the application programs need not be changed since they refer to the external schemas. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 20 DBMS Languages Data Definition Language (DDL) Data Manipulation Language (DML) High-Level or Non-procedural Languages: These include the relational language SQL May be used in a standalone way or may be embedded in a programming language Low Level or Procedural Languages: These must be embedded in a programming language Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 21 DBMS Languages Data Definition Language (DDL): Used by the DBA and database designers to specify the conceptual schema of a database. In many DBMSs, the DDL is also used to define internal and external schemas (views). In some DBMSs, separate storage definition language (SDL) and view definition language (VDL) are used to define internal and external schemas. SDL is typically realized via DBMS commands provided to the DBA and database designers Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 22 DBMS Languages Data Manipulation Language (DML): Used to specify database retrievals and updates DML commands (data sublanguage) can be embedded in a general-purpose programming language (host language), such as COBOL, C, C+ +, or Java. A library of functions can also be provided to access the DBMS from a programming language Alternatively, stand-alone DML commands can be applied directly (called a query language). Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 23 Types of DML High Level or Non-procedural Language: For example, the SQL relational language Are “set”-oriented and specify what data to retrieve rather than how to retrieve it. Also called declarative languages. Low Level or Procedural Language: Retrieve data one record-at-a-time; Constructs such as looping are needed to retrieve multiple records, along with positioning pointers. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 24 DBMS Interfaces Programmer interfaces for embedding DML in a programming languages: Pre-complier Approach. Procedure Call Approach: e.g. JDBC for Java, ODBC for other programming languages Stand alone query language interface: e.g. ORACLE has PL/SQL, a programming language based on SQL; language incorporates SQL and its data types as integral components Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 25 User-Friendly DBMS Interfaces Menu-based, popular for browsing on the web Forms-based, designed for naïve users Graphics-based (Point and Click, Drag and Drop, etc.) Natural language: requests in written English Combinations of the above: For example, both menus and forms used extensively in Web database interfaces Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 26 Other DBMS Interfaces Speech as Input and Output Web Browser as an interface Parametric interfaces, e.g., bank tellers using function keys. Interfaces for the DBA: Creating user accounts, granting authorizations Setting system parameters Changing schemas or access paths Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 27 Typical DBMS Component Modules Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 28 Database System Utilities Most DBMSs have DB utilities to perform certain functions such as: Loading data stored in an existing data files -such as text files- into a database. Includes data conversion tools. Backing up the database periodically on tape. Performance monitoring utilities. Reorganizing database file structures to improve performance. Other functions, such as sorting, user monitoring, data compression, etc. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 29 Other Tools Expanded Data dictionary / repository: In addition to storing catalog information about schema descriptions, it is Used to store other information such as design decisions, application program descriptions, user information, usage standards, etc. Used by DNMS softwrae, DB designers, DBAs, and users. Active data dictionary is accessed by DBMS software and users/DBA. Passive data dictionary is accessed by users/DBA only. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 30 Other Tools Application Development Environments and CASE (computer-aided software engineering) tools: Examples: PowerBuilder (Sybase) JBuilder (Borland) JDeveloper 10G (Oracle) Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 31 Classification of DBMSs Based on the data model used 1. Flat files 2. Traditional: Network and Hierarchical. 3. Relational data model. 4. Emerging: Object-oriented, Object-relational. Other classifications Based on number of users: Single-user (typically used with personal computers) vs. multi-user (most DBMSs). Based on number of sites: Centralized (uses a single computer with one database) vs. distributed (uses multiple computers, multiple databases) Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 32 Database Technology Evolution Era Generation Orientation Major Features 1960s 1st Generation File File structures and proprietary program interfaces 1970s 2nd Generation Network Networks and hierarchies Navigation of related records, standard program interfaces 1980s 3rd Generation Relational Non-procedural languages, optimization, transaction processing 1990s 4th Generation Object Multi-media, active, distributed processing, XML enabled Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 33 Distributed DBMS © Pearson Copyright © 2007 Ramez Elmasri and Shamkant B. NavatheEducation Limited 1995, 2005 34 Distributed Processing A centralized database that can be accessed over a computer network. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe 35 Variations of Distributed DBMSs (DDBMSs) Homogeneous DDBMS Heterogeneous DDBMS Federated or Multi-database Systems Distributed Database Systems have now come to be known as client-server based database systems because: They do not support a totally distributed environment, but rather a set of database servers supporting a set of clients. Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 36 Database Development Phases Conceptual Data Data Modeling requirements ERD Logical Database Design Tables Distributed Database Design Distribution Schema Physical Database Internal Schema, Design Populated DB Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 37 Conceptual Data Modeling Information content of the database Entity relationship diagram (ERD) showing entity types and relationships Historically, DBMSs did not support many constraints. Diverse formats for database requirements Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 38 Logical Database Design Refine conceptual design Convert ERD to table design Analyze design for excessive redundancies Normalization: tool to reason about redundancies Add constraints to enforce business rules Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 39 Distributed Database Design Location of data and processing Performance orientation, not information content orientation Allocate subsets of database to different sites Replicate subsets of database to improve availability Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 40 Physical Database Design Performed at each independent database site Minimize response time without consuming excessive resources Tradeoffs: retrieval versus update Flexible designs versus specialized(fixed) designs Decisions: indexes, data placement(clustering) Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 2- 41 Code // BuildTables.java // Create a new table, urlInfo, inside Books.mdb // The table has three columns: id, name, url import java.sql.*; public class simpJDBC { public static void main(String[] args) { // The URL for the Books database. // ’Protected' by a login and password. String url = "jdbc:odbc:Books"; String username = "anonymous"; String password = "guest"; : Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe // SQL table creation and insertion String[] SQLStats = { "create table urlInfo (id int,Name char(48), url char(80))", "insert into urlInfo values(1, ‘Daher Thabit', 'http://www.rss.gov.jo/~daher')", "insert into urlInfo values(2, ‘National Information Centre', 'http://www.nic.gov.jo')", "insert into urlInfo values(3, ‘Sun', 'http://www.sun.com')” }; try { // load the JDBC-ODBC Bridge driver Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // connect to db using DriverManager Connection conn = DriverManager.getConnection( url, username, password ); : Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe // Create a statement object Statement statement = conn.createStatement(); // Create urlInfo table for (int i = 0; i < SQLStats.length; i++) { statement.executeUpdate(SQLStats[i]); System.out.println("Processed: " + SQLStats[i]); } // Close down statement.close(); conn.close(); } : Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe catch ( ClassNotFoundException cnfex ) { System.err.println( "Failed to load JDBC/ODBC driver." ); cnfex.printStackTrace(); System.exit( 1 ); // terminate program } catch ( SQLException sqlex ) { System.err.println( sqlex ); sqlex.printStackTrace(); } } // end of main() } // end of BuildTables class Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe

Use Quizgecko on...
Browser
Browser