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

Chapter 2 Relational Data Model

Uploaded by

hafaking480
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Chapter 2 Relational Data Model

Uploaded by

hafaking480
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 39

1

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

2
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2.1 Database System Concepts and
Architecture/RDM

3
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.
4
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


5
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
6
Cont….

7
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont….

8
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont….

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).
9
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

10
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.

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

12
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.

13
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

14
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont…

15
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.

16
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.
17
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
18
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2.4. Data Independence

19
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.
20
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

21
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.
22
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2.5 DBMS Languages

23
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont..

24
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.

25
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

27
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont…

28
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.

29
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

30
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.

31
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Centralized DBMs

32
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.)

33
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.

34
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


35
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

36
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

37
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. 38
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
39
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe

You might also like