570 likes | 1.11k Views
Database System Concepts and Architecture. Data Models. A set of concepts to describe the structure of a database. The structure includes data types, relationships and constraints. Data Model Operations
E N D
Data Models • A set of concepts to describe the structure of a database. • The structure includes data types, relationships and constraints. • Data Model Operations • Operations for specifying database retrievals and updates by referring to the concepts of the data model. • Data model may include basic operations and user-defined operations
Database Schemas • Database Schema • The description of a database using the given data model. • Example: the database consists of information about a set of customers and accounts and the relationship between them • Analogous to type information of a variable in a program • Schema Diagram • An illustrative display of a database schema. • Schema Construct • A component of the schema or an object within the schema, e.g., STUDENT, COURSE.
Data Model and Schema • The relational model of datais the most widely used model today • Main concept: relation, basically a table with rows and columns. • Every relation has a schema, which describes the columns, or fields.
Database State • Database State • Refers to the content of a database at a moment in time. • Also called database instance or occurrence. • Analogous to the value of a variable • Initial 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
Schemas versus State • Schema changes very infrequently, whereas state changes every time the database is updated. • Schema is also called intension, whereas state is called extension. Database Schema Database State
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-basedorobject-based data models. • Physical (low-level, internal) data models • Provide concepts that describe details of how data is stored in the computer. • Implementation (representational) data models • Provide concepts that fall between the above two, balancing user views with some computer storage details. It includes relational data model.
Entity-Relationship Model • Example of schema in the entity-relationship model
Relational Data Model • A Sample Relational Database
Three-Schema Architecture • Proposed to support DBMS characteristics of: • Insulation of programs and data • Program data independence • Program operation independence • Support of multiple views of the data. • Use of catalog to store schema
Three-Schema Architecture • Defines DBMS schemas at three levels: • Internal schema describes physical storage structures and access paths. • Typically uses a physical data model. • Conceptual schema describes the structure and constraints for the database for a community of users. • Uses a conceptual or an implementation data model. • External schemas describes the various user views. • Usually uses the same data model as the conceptual schema.
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)
Data Independence • Logical Data Independence • The capacity to change the conceptual schema without having to change the external schemas and their associated application programs. (Only the mappings need to be changed in DBMS) • 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 • One of the most important benefits of using a DBMS!
DBMS Languages • Data Definition Language (DDL) • Data Manipulation Language (DML)
DBMS Languages • Data Definition Language (DDL): • Used by the DBA and database designers to specify the conceptual schema of a database. • Specification (notation) for defining the database schema. E.g. create tableaccount (account-numberchar(10),balanceinteger) • Storage definition language (SDL) is used to specify internal schema. • View definition language (VDL) is used to define views and their mapping to conceptual schema.
DBMS Languages • Data Manipulation Language (DML) • Used to specify database retrievals and updates • Two classes of languages • Procedural (Low Level ) • user specifies what data is required and how to get those data • These must be embedded in a programming language • Nonprocedural (High Level ) • user specifies what data is required without specifying how to get those data • May be used in a standalone way(query language) or may be embedded in a programming language (host language)
DBMS Interfaces • Stand-alone query language interfaces • Example: Entering SQL queries at the DBMS interactive SQL interface (e.g. SQL*Plus in ORACLE) • Programmer interfaces for embedding DML in programming languages • User-friendly interfaces such as • Menu-based, forms-based, graphics-based, etc.
Database System Utilities • To perform certain functions such as: • Loading data stored in existing files into a database. Includes data conversion tools. • Backing up the database periodically on tape. • Reorganizing database file structures. • Report generation utilities. • Performance monitoring utilities. • Other functions, such as sorting, user monitoring, data compression, etc.
Data dictionary / repository • Used to store schema descriptions and other information such as design decisions, application program descriptions, user information, usage standards, etc. • Active data dictionary is accessed by DBMS software and users/DBA. • Passive data dictionary is accessed by users/DBA only.
DBMS Architectures • Centralized DBMS • Combines everything into single system including- DBMS software, hardware, application programs, and user interface processing software. • User can connect through a remote terminal.
Basic 2-tier Client-Server Architectures • Client • a user machine with user interface capabilities and local processing. • It can access the specialized servers as needed • Server • contains both hardware and software that provide services to clients , such as printing, file access, or database access
DBMS Server • Provides database query and transaction services to the clients • Relational DBMS servers are often called SQL servers, query servers, or transaction servers • Applications running on clients utilize an Application Program Interface (API) to access server databases via standard interface such as: • ODBC: Open Database Connectivity standard • JDBC: for Java programming access
Two Tier Client-Server Architecture • A client program may connect to several DBMSs, sometimes called the data sources. • In general, data sources can be files or other non-DBMS software that manages data. • Other variations of clients are possible: e.g., in some object DBMSs, more functionality is transferred to clients including data dictionary functions, optimization and recovery across multiple servers, etc.
Three Tier Client-Server Architecture • Adds Intermediate layer called Application Server or Web Server. • Middle Tier stores business logic that is use to access data from the database server • Enhance security as DB server is only accessible via middle tier
Classification of DBMSs • Based on the data model used • Traditional: Relational, Network, Hierarchical. • Emerging: Object-oriented, Object-relational. • Single-user (typically used with personal computers)vs. multi-user (most DBMSs). • Centralized (uses a single computer with one database) vs. distributed (uses multiple computers, multiple databases)
Record-based Logical Models • Describe data at the conceptual and view levels. • Specify overall logical structure of the database • Provide a higher-level description of the implementation. • The database is structured in fixed-format records of several types. • Each record defines a fixed number of fields, or attributes. • Each field is usually of a fixed length (this simplifies the implementation). • The three most widely-accepted models are • relational, • network, and • hierarchical.
Relational Model • Data and relationships are represented by a set of tables. • A tuple or row contains all the data of a single instance of the table. • Eachtable has a number of columns with unique names • Every tuple must have a unique identification or key based on the data.
Network Model • Data are represented by collections of records. • Relationships among data are represented by links. • Organization is that of an arbitrary graph.
Hierarchical Model • Similar to the network model. • Organization of the records is as a collection of trees, rather than arbitrary graphs. • The relational model does not use pointers or links, but relates records by the values they contain. This allows a formal mathematical foundation to be defined.
Object Data Model • Defines database in terms of objects, their properties and operations. • Objects with same structure and behavior belong to a class • Classes are organized into hierarchies • The operations of each class are specified as methods • Internal parts of the object, the instance variables and method code, are not visible externally. • Describe data at the conceptual and view levels. • Allow one to specify data constraints explicitly.
Example: Object Data Model For example, consider an object representing a bank account. • The object contains instance variables number and balance • The object contains a method pay-interest which adds interest to the balance. • Under most data models, changing the interest rate entails changing code in application programs. • In the object-oriented model, this only entails a change within the pay-interest method.
Distributed DBMSs (DDBMSs) • Distributed Database Systems can have database and DBMS software distributed over many • Homogeneous DDBMS • Heterogeneous DDBMS • Federated or Multidatabase Systems • Uses client-server architecture