You are on page 1of 14

5/18/2021

Outlines

 Data Models
Chapter 2  Schema, Instances and States

Database System Concepts and Architecture  DBMS Architecture and Data Independence

 Database Language and Interface

 The Database System Environment

 Classification of DBMS

Data Models Data Models (continued)


 Data Model:  Data Model Operations:
 A set of concepts to describe the structure of a database, the
 These operations are used for specifying database
operations for manipulating these structures, and certain
constraints that the database should obey.
retrievals and updates by referring to the constructs

 Data Model Structure and Constraints: of the data model.

 Constructs are used to define the database structure  Operations on the data model may include basic
 Constructs typically include elements (and their data types) as model operations (e.g. generic insert, delete,
well as groups of elements (e.g. entity, record, table), and
update) and user-defined operations (e.g.
relationships among such groups
compute_student_gpa, update_inventory)
 Constraints specify some restrictions on valid data; these
constraints must be enforced at all times

1
5/18/2021

Categories of Data Models Data Models, Schemas, and


 Conceptual (high-level, semantic) data models:
Instances
 Provide concepts that are close to the way many users perceive data.  Data abstraction
• (Also called entity-based or object-based data models.)
 Suppression of details of data organization and
 Physical (low-level, internal) data models:
 Provide concepts that describe details of how data is stored in the
storage
computer.  Highlighting of the essential features for an
 Access path: Structure that makes the search for particular database improved understanding of data
records efficient
 Index: Allows direct access to data using an index term or a keyword.
Example of an access path
 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).

Schemas, Instances, and Database State


 Database Schema:
Schemas, Instances, and Database State
 The description of a database.
 Includes descriptions of the database structure(organization of data and
 Database State:
the relationships between tables), data types, and the constraints on the  The actual data stored in a database at a
database/that should hold on the database.
 Is an abstract design that represents the storage of your data in a particular moment in time. This includes the
database. collection of all the data in the database.
 Developers plan a database schema in advance so they know what
components are necessary and how they will connect to each other.  Also called database instance (or occurrence
 Schema Diagram: or snapshot).
 An illustrative display of (most aspects of) a database schema. • The term instance is also applied to individual
A diagrammatic display of (some aspects of) a database database components, e.g. record instance, table
schema instance, entity instance
 Schema Construct:
 A component of the schema or an object within the schema,  Database Instance: The actual data stored in a
e.g., STUDENT, COURSE. database at a particular moment in time. Also called
database state (or occurrence).

2
5/18/2021

Database Schema vs. Database State Example of a Database Schema


 Database State: Refers to the content of a database at a
moment in time.
 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.
• Distinction
• The database schema changes very infrequently. The
database state changes every time the database is
updated.
• Schema is also called intension, whereas state is
called extension.

Objectives of Three-Level Architecture


Example of a database state
 Objectives of Three-Level Architecture:
 All users should be able to access same data.
 A user’s view is immune to changes made in other views.
 Users should not need to know physical database storage details.
 DBA should be able to change database storage structures without
affecting the users’ views.
 Internal structure of database should be unaffected by changes to
physical aspects of storage.
 DBA should be able to change conceptual structure of database without
affecting all users.

3
5/18/2021

Three-Schema Architecture 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).
 Proposed to support DBMS characteristics of: • Typically uses a physical data model.
 The design of a database at physical level is called physical schema, how the data stored in blocks of
 Program-data independence. storage is described at this level

 Conceptual schema at the conceptual level to describe the structure and


 Support of multiple views of the data. constraints for the whole database for a community of users.
• Uses a conceptual or an implementation data model.
 Design of database at logical level is called logical schema, programmers and database administrators
work at this level, at this level data can be described as certain types of data records gets stored in data
structures, however the internal details such as implementation of data structure is hidden at this level
(available at physical level).

 External schemas at the external level to describe the various user


views.
• Usually uses the same data model as the conceptual schema.
 Design of database at view level is called view schema. This generally describes end user interaction with
database systems.

The three-schema architecture Three-Schema Architecture (continued)


 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)

4
5/18/2021

Data Independence Data Independence (continued)


 The fact that the logical and physical databases are distinguished and  Physical Data Independence:
(ideally, at least) kept rigidly apart is what allows us to achieve the  The capacity to change the internal schema/physical schema
important goal of data independence. without having to change the conceptual schema.
 Data independence—Allow users a freedom to change the way the  For example, the internal schema may be changed when certain
database is physically stored and accessed without having to make file structures are reorganized or new indexes are created to
corresponding changes to the way the database is perceived by the user. improve database performance
 Logical Data Independence:  Changes in the physical schema may include.
 The ability to change the conceptual schema/logical schema without • Using new storage devices.
having to change the external schemas and their associated • Using different data structures.
application programs. • Switching from one access method to another.
 The ability to change the logical schema without changing the external • Using different file organizations or storage structures.
schema or application programs • Modifying indexes.

 Example: The addition or removal of new entities, attributes,  Examples: A change to the internal schema, such as using different
or relationships to the conceptual schema should be possible file organization.
without having to change existing external schemas or having  Or storage structures, storage devices, or indexing strategy,
to rewrite existing application programs. should be possible without having to change the conceptual or
external schemas.

Data Independence (continued) Differences between Three Levels of


 When a schema at a lower level is changed, ANSI-SPARC Architecture
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.

5
5/18/2021

Data Independence and the ANSI- DBMS Languages


SPARC Three-Level Architecture  Data Definition Language (DDL): helps you to define the database structure
or schema.
 DDL commands in SQL
• CREATE: CREATE statements is used to define the database
structure schema
• DROP: Drops commands remove tables and databases from RDBMS.
• ALTER: Alters command allows you to alter the structure of the
database
 Data Manipulation Language (DML): Allows you to modify the database
instance by inserting, modifying, and deleting its data.
 It is responsible for performing all types of data modification in a
database.
 DML commands in SQL:
• INSERT: is used to insert data into the row of a table.
• UPDATE: used to update or modify the value of a column in the table
• DELETE: used to remove one or more rows from a table

DBMS Languages (continued) DBMS Languages (continued)


 Data Definition Language (DDL):
 Data Manipulation Language (DML):
 Used by the DBA and database designers to specify the
 Used to specify database retrievals and updates
conceptual schema of a database.
 DML commands (data sublanguage) can be embedded in a
 In many DBMSs, the DDL is also used to define internal and
general-purpose programming language (host language), such as
external schemas (views).
COBOL, C, C++, or Java.
 In some DBMSs, separate storage definition language (SDL)
• A library of functions can also be provided to access the DBMS
and view definition language (VDL) are used to define
from a programming language
internal and external schemas.
 Alternatively, stand-alone DML commands can be applied directly
• SDL is typically realized via DBMS commands provided to
(called a query language).
the DBA and database designers

6
5/18/2021

DML and DDL Examples: Types of DML


 DML  High Level or Non-procedural Language:
INSERT INTO students (RollNo, FIrstName, LastName) VALUES ('60',  For example, the SQL relational language
'Tom', Erichsen');  Is used to declare what data is needed-not how the data is retrieved.
UPDATE students SET FirstName = 'Jhon', LastName= 'Wick' WHERE  Are “set”-oriented and specify what data to retrieve rather than how to
StudID = 3; retrieve it.
DELETE FROM students WHERE FirstName = 'Jhon';  Also called declarative languages.
SELET *FROM students; • May be used in a standalone way or may be embedded in a
programming language
 DDL:  Low Level or Procedural Language:
Create database university; Drop object_type object_name;
 Is used to tell the system what data is needed and how to take the data.
Create table students; Drop database university;
 Retrieve data one record-at-a-time;
Create view for_students; Drop table student;  Constructs such as looping are needed to retrieve multiple records, along
Alter table guru99 add subject varchar; with positioning pointers.
 is embedded into a high-level programming language.

Types of DML (continued) DBMS Interfaces


 Example of Non Procedural DML:
SELECT … FROM … WHERE …  Stand-alone query language interfaces
INSERT INTO … VALUES …
 Example: Entering SQL queries at the DBMS interactive SQL
UPDATE … SET … WHERE …
DELETE FROM … WHERE … interface (e.g. SQL*Plus in ORACLE)
Example of SQL statement:  Programmer interfaces for embedding DML in programming
INSERT INTO Persons (Id, LastName, FirstName) VALUES (5, 'Azuharu',
'Fahmi') languages
 Example of Low Level or Procedural Language:  User-friendly interfaces
Statement st = connection.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM students");
 Menu-based, forms-based, graphics-based, etc.
while(rs.next){
String s = rs.getString(1);
 Resultset declare what data is needed, which are included in the line of the
SQL query SELECT * FROM students. While the while line states the way to
retrieve the data.

7
5/18/2021

DBMS Programming Language Interfaces User-Friendly DBMS Interfaces


 Programmer interfaces for embedding DML in a programming  Menu-based, popular for browsing on the web
languages:
 Forms-based, designed for naïve users
 Embedded Approach: e.g embedded SQL (for C, C++, etc.),
 Graphics-based
SQLJ (for Java)
• (Point and Click, Drag and Drop, etc.)
 Procedure Call Approach: e.g. JDBC for Java, ODBC for other
programming languages  Natural language: requests in written English

 Database Programming Language Approach: e.g. ORACLE has  Combinations of the above:
PL/SQL, a programming language based on SQL; language • For example, both menus and forms used
incorporates SQL and its data types as integral components extensively in Web database interfaces

Other DBMS Interfaces The Database System Environment


 Speech as Input and Output
 DBMS component modules
 Web Browser as an interface
 Buffer management
 Parametric interfaces, e.g., bank tellers using
Schedule disk read/write, because this has a considerable effect on
function keys. performance. Reducing disk read/write improves performance
 Interfaces for the DBA: considerably.

• Creating user accounts, granting authorizations  Stored data manager


• Setting system parameters controls access to DBMS information that is stored on disk, whether
• Changing schemas or access paths it is part of the database or the catalog.

8
5/18/2021

The Database System Environment (cont'd.) The Database System Environment (cont'd.)

Interactive query interface-Interface that casual  Precompiler extracts DML commands from an
users and persons with occasional need for information application program written in a host
from the database interact.
programming language. These commands are
 query compiler that compiles queries into an internal sent to the DML compiler for compilation into
form. Queries are parsed and validated for correctness of
the query syntax, the names of files and data elements,
object code for database access. The rest of the
and so on program is sent to the host language compiler.
 Query optimizer concerned with the rearrangement and The object codes for the DML commands and the
possible reordering of operations, elimination of rest of the program are linked, forming a canned
redundancies, and use of correct algorithms and indexes transaction whose executable code includes calls
during execution. to the runtime database processor.

The Database System Environment (cont'd.)

 DBMS component modules


 Runtime database processor executes:
(1) the privileged commands,
(2) the executable query plans,
and (3) the canned transactions with runtime parameters.
 System catalog
 Concurrency control system
 Backup and recovery system

9
5/18/2021

Centralized and Client/Server Architectures DBMS Server


for DBMSs
 Provides database query and transaction services to the
 Centralized DBMSs Architecture clients
 Relational DBMS servers are often called SQL servers,
 Combines everything into single system including- query servers, or transaction servers
DBMS software, hardware, application programs,  Applications running on clients utilize an Application
Program Interface (API) to access server databases via
and user interface processing software. standard interface such as:
 ODBC: Open Database Connectivity standard
 User can still connect through a remote terminal –  JDBC: for Java programming access
however, all processing is done at centralized site  Client and server must install appropriate client module
and server module software for ODBC or JDBC

Two-Tier Client/Server Architectures for


DBMSs Two-Tier Client/Server Architectures (cont'd.)

 A client program may connect to several DBMSs,  Open Database Connectivity (ODBC)
sometimes called the data sources.  Provides application programming interface
 In general, data sources can be files or other non- (API)
DBMS software that manages data.  Allows client-side programs to call the DBMS
 Other variations of clients are possible: e.g., in • Both client and server machines must have the
some object DBMSs, more functionality is necessary software installed
transferred to clients including data dictionary  JDBC
functions, optimization and recovery across
 Allows Java client programs to access one or
multiple servers, etc.
more DBMSs through a standard interface

10
5/18/2021

Three-Tier and n-Tier Architectures for


Web Applications
 Common for Web applications
 Intermediate Layer called Application Server or Web
Server:
 Stores the web connectivity software and the business logic
part of the application used to access the corresponding
data from the database server
 Acts like a conduit for sending partially processed data
between the database server and the client.
 Three-tier Architecture Can Enhance Security:
 Database server only accessible via middle tier
 Clients cannot directly access database server

Classification of Database
Database Models
Management Systems
 A specific DBMS has its own specific Data Definition Language,
 Based on the data model used but this type of language is too low level to describe the data
requirements of an organization in a way that is readily
 Traditional: Relational, Network, Hierarchical. understandable by a variety of users.
 Emerging: Object-oriented, Object-relational.  We need a higher-level language.
 Other classifications  Such a higher-level is called data-model.
 Single-user (typically used with personal  A data model is a collection of tools or concepts for describing
computers) data, the meaning of data, data relationships, and data
vs. multi-user (most DBMSs). constraints.
 A model is a representation of real world objects and events and their
 Centralized (uses a single computer with one
associations.
database)
 The main purpose of Data Model is to represent the data in
vs. distributed (uses multiple computers,
understandable way.
multiple databases)

11
5/18/2021

Database Models … Cont’d Hierarchical Model


 Consists of an ordered set of trees in a parent child mode.
 A database model is a type of data model that determines the  A parent node can have more than one child node and a child node should
logical structure of a database and fundamentally determines in have only one parent
 Connection between child and its parent is called a Link.
which manner data can be stored, organized, and manipulated.
 The simplest data model
 Data model can be divided into four:  Record type is referred to as node or segment
 The top node is the root node
1) Hierarchical Model
 The relationship between parent and child can be either 1-1 or 1-M
2) Network Model  To add new record type or relationship, the database must be redefined and
then stored in a new form.
3) Relational Model

4) Object oriented Model

Network Model
Hierarchical Model… Cont’d
 Allows record types to have more that one parent unlike hierarchical
Advantage of Hierarchical Model model
 Good for tree type problem (e.g. Family Tree Problem)  A network data models sees records as set members
 Language is simple; uses constructs like GET, GET UNIQUE, GET  Each set has an owner and one or more members
NEXT, GET NEXT WITHIN PARENT etc.  Allow no many to many relationship between entities
 Like hierarchical model network model is a collection of physically
Disadvantages of Hierarchical Model linked records.
 Addition, deletion, and search operations are very difficult.  Allow member records to have more than one owner
 There is duplication of data.
 Navigational and procedural nature of processing
 Database is visualized as a linear arrangement of records
 Little scope for "query optimization"

12
5/18/2021

Object Oriented Model


Network Model … Cont’d
Advantage of Network Data Model:
 The OO approach of defining objects that can be used in many programs
 Network Model is able to model complex relationships and represents
semantics of add/delete on the relationships. is now also being applied to database systems.
 Can handle most situations for modeling using record types and  An object can have properties (or attributes) but also behaviour, which
relationship types.
is modelled in methods (functions) in the object.
 Language is navigational; uses constructs like FIND, FIND member,
FIND owner, FIND NEXT within set, GET etc.  In an OO database , each type of object in the database’s mini-world is
Disadvantages of Network Data Model:
modelled by a class i.e. (Customer class, Account class ) like tables in
 Navigational and procedural nature of processing
the relational model.
 Database contains a complex array of pointers that thread through a
set of records.  A class has properties (attributes).
 Little scope for automated "query optimization”
 A class also has methods that are stored with the class definition.

Object Oriented Model … Cont’d Object Oriented Model … Cont’d


 One advantage of the OO model is sub-classes. As there are different
Diagram – class name at the top, properties in the middle, methods at the bottom.
types of account, they can be modelled as sub-classes of the Account
class.

 SavingsAccount and CurrentAccount.

 This makes sense because the different account types have some
different behaviour e.g. gaining interest in a savings account but
some behaviour the same e.g. lodging or withdrawing cash. This is
the inheritance concept of OO programming.

13
5/18/2021

Relation Model Relational Model … Cont’d


 Developed by Dr. Edgar Frank Codd in 1970 (famous paper, 'A  Records are related by the data stored jointly in the fields of records in
Relational Model for Large Shared Data Banks') two tables or files. The related tables contain information that creates
the relation
 Terminologies originates from the branch of mathematics called set
theory and relation  The tables seem to be independent but are related some how.
 Can define more flexible and complex relationship  No physical consideration of the storage is required by the user
 Viewed as a collection of tables called “Relations” equivalent to  Many tables are merged together to come up with a new virtual view
collection of record types of the relationship
 Relation: Two dimensional table
 Stores information or data in the form of tables ( rows and columns)
 A row of the table is called tuple which is equivalent to record
 A column of a table is called attribute which is equivalent to fields
 Data value is the value of the Attribute

Relational Model … Cont’d


Relational Data model (also called the second generation data
model), describes entities and their relationships in the form of table

Entity : Student Entity: course

Id Name Courseno Course no. Course_title Credit_hours


123 Abebe K. INST 321

INST 321 Database Systems 3


234 Almaz M. INST 205

456 Abebe W. INST 321 INST 205 Introduction to ICT 3

14

You might also like