0% found this document useful (0 votes)
14 views

Chapter 2 Relational Data Model

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Chapter 2 Relational Data Model

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Copyright © 2007 Ramez Elmasri and Shamkant B.

Navathe
 You will learn or know the following topic
 Relational data model
 Basic terminology of RDM
 The 3 schema architecture
 Types of data independency
 The basic criteria of DBMS classification
 About distributed and centralized DBMS

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


2.1 Database System Concepts and
Architecture/RDM
 Relational data model is the primary data model,
which is used widely around the world for data
storage and processing. This model is simple and it
has all the properties and capabilities required to
process data with storage efficiency.
 Terminology/concepts:- is the study of terms and

their use. Terms are words and compound words or


multi-word expressions that in specific contexts are
given specific meanings—these may deviate from the
meanings the same words have in other contexts and
in everyday language Schema

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


• Tables
• Tuples
• Relational instances
• Relational schema
• Relation key
• Attribute domain
• Tables − In relational data model, relations are saved in
the format of Tables. This format stores the relation
among entities. A table has rows and columns, where
rows represents records and columns represent the
attributes.
• Tuple − A single row of a table, which contains a single
record for that relation is called a tuple.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont….

• Relation instance(state) − A finite set of tuples in the


relational database system represents relation instance.
Relation instances do not have duplicate tuples

• Relation schema − A relation schema describes the relation


name (table name), attributes, and their names.
Student( sid , Name , Age , Gpa…..)
• Schema diagram:- An illustrative display of (most aspects

of) a database schema.


 eg student

Sid Name Age Gpa

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont….
 Attribute domain − Every attribute has some pre-defined
value scope, known as attribute domain.
- The domain of an attribute A, denoted by Dom(A), is the
set of values that the attribute can take.
 A domain is usually represented by a type. E.g.,

 SID char(4)

 Name varchar(30) --- character string of variable

length up to 30
 Age number --- a number

Relation key − Each row has one or more attributes, known


as relation key, which can identify the row in the relation
(table) uniquely.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont….

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont….
• Schema Construct:
A component of the schema or an object within the schema, e.g.,
STUDENT, COURSE.
• Distinction//deference
The database schema changes very infrequently.
(e.g., adding, deleting, renaming attributes and deleting a table
schema) but it is infrequent
The database state changes every time the database is updated.
(e.g., inserting or deleting a tuple, and changing an attribute value
in a tuple) & it is frequent
• Schema is also called intension.
• State is also called extension.
The intension of a database is the set of definitions of the data
structures for the particular database (also called schema).
The extension of the database is the set of database values that
populate these data structures.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont….
A schema may have different states at different times.
Properties of Relational Tables:
1. Data is presented as a collection of relations.
2. Each relation is depicted as a table.
3. Columns are attributes that belong to the entity modeled by the
table (ex. In a student table, you could have name, address,
student ID, major, etc.).
4. Each row ("tuple") represents a single entity
(ex. In a student table, John Smith, 14 Oak St, 9002342,
Accounting, would represent one student entity).
5. Every table has a set of attributes that taken together as a "key"

(technically, a "super key") uniquely identifies each entity (Ex. In


the student table, “student ID” would uniquely identify each
student – no two students would have the same student ID).
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2.2. Constraints of Relational data model

Every relation has some conditions that must hold for it


to be a valid relation. These conditions are
called Relational Integrity Constraints.
There are three main integrity constraints −
1.Key constraints

2.Domain constraints

3.Referential integrity constraints

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


1. Key constraint
 There must be at least one minimal subset of attributes in
the relation, which can identify a tuple uniquely. This
minimal subset of attributes is called key for that relation.
If there are more than one such minimal subsets, these are
called candidate keys.
Key constraints force that −
 In a relation with a key attribute, no two tuples can have

identical values for key attributes.


 a key attribute can not have NULL values.

 Key constraints are also referred to as Entity Constraints.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont….
2. Domain Constraints
Attributes have specific values in real-world scenario.
For example, age can only be a positive integer. The same
constraints have been tried to employ on the attributes of a
relation.
Every attribute is bound to have a specific range of values.
For example, age cannot be less than zero and telephone
numbers cannot contain a digit outside 0-9.
Sid varchar(35)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


3. Referential integrity Constraints
 Referential integrity constraints work on the concept
of Foreign Keys. A foreign key is a key attribute of a
relation that can be referred in other relation.
 Referential Integrity Constraint: No relation can
contain unmatched foreign key values.
 Using foreign keys in a relation to reference primary
keys of other relations is the only way in the relational
data model to establish relationships among different
relations.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


2.3 Three-Schema Architecture
• Three-schema architecture is an idea in relational database
design that breaks a database down into three different
categories according to its use and structure, and to the roles
played by system administrators, designers and end users.
• The goal of the three-schema architecture, illustrated in
Figure2.2, is to separate the user applications and the physical
database.
In this architecture, schemas can be defined at the three levels:
1. Internal (Physical) Level
2. Conceptual (Logical) Level
3. External (View) Level

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont…

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont..
1. Internal (Physical) Level
The internal level has an internal schema is also known as
physical level, which describes the physical storage structure of the
database.
• The internal schema uses a physical data model and Describes

the complete details of data storage and access paths for the
database
 It is the lowest level of data abstraction that deals with the

physical representation of the database on the computer .


 The database users and the application programmers are not

aware of storage by word or byte details; however, the DBA may


be aware of certain details of the physical organization of the
data.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2. Conceptual (logical) level
The conceptual level (logical level)has a conceptual schema,
which describes the structure of the whole database for a
community of users.
 The conceptual schema hide the details of physical storage

structure and concentrates on describing entities, data


types, relationships, user operations, and constraints.
 The conceptual view is the overall view of the database

and it includes all the information that is going to be


represented in the database.
 It describes what data is stored in the database, the

relationships among the data and complete view of the


user’s requirements without any concern for the physical
implementation.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
3. External (view) level
The external or view level includes a number of external
schemas or user views.
 It is the highest level of abstraction
 In general, most of the users and application programs do
not require the entire data stored in the database
 Each external schema describes the part of the database
that a particular user Group is interested in and hides
the rest of the database from that user group.
 As in the previous case, each external schema is
typically implemented using presentational data model,
possibly based on an external schema design in a high
level data model

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


2.4. Data Independence
 Data Independence can be defined as the capacity to change the
schema at one level of a Database system with out having to change
the schema at the next higher level.
 A database system normally contains a lot of data in addition to
users’ data. For example, it stores data about data, known as
metadata, to locate and retrieve data easily.
 Metadata summarizes basic information about data, which can make
finding and working with particular instances of data easier. For
example, author, date created and date modified and file size ..
 Data Independence can be Two types:
1. Logical data independence
2. Physical data independence

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe 19


1. Logical Data Independence

• The capacity to change the conceptual schema without having to


change the external schemas and their associated application
programs.
 We may change the conceptual schema to expand the database(by
adding a record type or data item), to change constraints, or to
reduce the database(by removing a record type or data item).
 include addition or deletion of fresh entities, attributes or
relationships and should be possible without having alteration to
existing external schemas.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe 20
2. Physical Data Independence
 The capacity to change the internal schema without
having to change the conceptual schema and external
schema.
 Changes to the internal schema may be needed because

some physical files had to be reorganized.


For example, by creating additional access structures-to
improve the performance of retrieval or update. If the same
hardware storage of encoding, exact location of data on
disk, merging of records, so on this are hidden from user

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont…
 Data as before remains in the database, we should not have
to change the conceptual schema. Alteration in the
internal(physical) schema might include.
 Using new storage devices.
 Using different data structures.
 Switching from one access method to another.
 Using different file organizations or storage structures.
 Modifying indexes.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


2.5 DBMS Languages
1. 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
 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 Languages:
 These must be embedded in a programming 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
Cont..
2. Data Definition Language (DDL):
 In some DBMSs, separate storage definition language

(SDL) and view definition language (VDL) are used to


define internal and external schemas.
 Storage Definition Language (SDL) :-used to specify the

internal schema. SDL is typically realized via DBMS


commands provided to the DBA and database designers
 View Definition Language (VDL):- to specify user views

and their mappings to the conceptual schema, but in most


DBMSs the DDL is used to define both conceptual and
external schemas.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


2.6 DBMS Interfaces
 Forms-Based Interfaces: displays a form to each user.
Users can fill out all of the form entries to insert new data, or they
fill out only certain entries, in which case the DBMS will retrieve
matching data for the remaining entries.
 Graphical User Interfaces (GUI): displays a schema to the user
in diagrammatic form. The user can then specify a query by
manipulating the diagram. In many cases, GUIs utilize both menus
and forms. Most GUIs use a pointing device, such as a mouse , to
pick certain parts of the displayed schema diagram. Creating table
and database diagrammatically.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont….
 Natural Language Interfaces: accept requests written in English
or some other language and attempt to "understand“ them.
- A natural language interface Usually has it s own“ schema ,“
which is similar to the database conceptual schema , as well as
a dictionary of important words.
- The natural language interface refers to the words in its schema,
as well as to the set of standard words in its dictionary, to
interpret the request.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide 1- 26 26


Database system utility
 Database system utility:-most DBMS have database Utilities
that help the DBA in managing the database system.
 A loading utility is used to load existing data files-such as text
files or sequential files-into the database .
 Backing up :-The backup copy can be used to restore the
database in case of catastrophic failure Backing up the database
periodically on tape.
 Reorganizing database file structures. This utility can be used to
reorganize a database file into a different file organization to
improve performance.
 Report creation utilities.
 Performance monitoring utilities.
 Other functions, such as sorting, user monitoring, data
compression, etc.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont…
 Data dictionary / repository:
 Used to store schema descriptions and other information such

as design decisions, application program descriptions, user


information, usage standards, etc.
 is a collection of descriptions of the data objects or items in

a data model for the benefit of programmers and others who


need to refer to them. A first step in analyzing a system of
objects with which users interact is to identify each object and
its relationship to other objects.
 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


2.6. Classification of DBMS

 Several criteria are normally used to classify DBMSs.


 The first is the data model(relational data model, object
oriented data model, hierarchical and network data
models)
 The 2nd number of users supported by the system.
 Single-user systems support only one user at a time and
are mostly used with Personal computers.
 Multiuser systems, which include the majority of DBMSs,
support multiple users concurrently.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont…
 The 3rd number of sites over which the database is
distributed
- DBMS is centralized if the data is stored at a single
computer site. A centralized DBMS can Support multiple
users, but the DBMS and the database them selves reside
totally at a single computer site.
 Logical two-tier client server architecture

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont…
• Specialized Servers with Specialized functions include:
- Print server
- File server
- DBMS server
- Web server
- Email server
• Clients can access the specialized servers as needed.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Centralized DBMs
• A single database maintained in one location managed by a
database administrator is usually accessed via a
communications network.
– LAN
– WAN
Advantages
Increased reliability and availability
Modular (incremental) growth
Lower communication costs
Faster Response
Disadvantages
Software cost and complexity
Processing overheads
Eg: Banks
Airline reservation systems
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Clients
 Provide appropriate interfaces through a client
software module to access and utilize the
various server resources.
 Clients may be diskless machines or PCs or
Workstations with disks with only the client
software installed.
 Connected to the servers via some form of a
network.
 (LAN: local area network, wireless network, etc.)

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


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
 Client and server must install appropriate client
module and server module software for ODBC.

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Distributed DBMs
• uses multiple computers, multiple databases.
A single logical database that is spread physically across computers
in multiple locations that are connected by a data communications
link.
• Most processing is local
• Need for local ownership of data
• Data sharing is required
• Note that users think they are working with a single corporate
database.
Advantages
 Minimize communications
Costs
Local control
Disadvantages
 Complex software
 Database design is difficult
 difficult to Handling failures
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Three Tier Client-Server Architecture
 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 medium for sending partially processed data
between the database server and the client.
 Three-tier Architecture Can increase Security:
 Database server only accessible via middle tier
 Clients cannot directly access database server

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Logical 3 tire client server architecture

Client application server /web server DB server

GUI/ Application Database


web program/we managemen
interface b page t system

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe


Cont…
• An application program is any program designed
to perform a specific function directly for the user
or, in some cases, for another application
program.
• Examples of application programs include:
– word processors;
– database programs;
– Web browsers;
– development tools;
– drawing,
– paint,
– image editing programs; and
– communication programs.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Thank you

Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe

You might also like