Chapter 2 Relational Data Model
Chapter 2 Relational Data Model
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….
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….
2.Domain 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
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
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
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
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.
27
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Cont…
28
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
2.6. Classification of DBMS
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,
34
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Distributed DBMs
•uses multiple computers, multiple databases.
database.
Advantages
Minimize communications
Costs
Local control
Disadvantages
Complex software
36
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe
Logical 3 tire client server architecture
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