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

Lecture 03

Uploaded by

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

Lecture 03

Uploaded by

aashir.aftab01
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Database

Management
System

Lecture - 03
Database Model
• Database model defines the logical design of data.
• Database model describes the relation between different
parts of data.
• There are three database models:
1. Hierarchical Model
2. Network Model
3. Relational Model
Hierarchical Model

• Data are organized in an upside down tree


• Each entity has one parent and many children
• Old and not used now
Network Model

• Entities are organized in a graph


• Entities can be accessed through several paths
• Old and not used
Relational Model

• Data are organized in two dimensional tables (relations)


• Tables related to each other
• Relational Database Management System (RDBMS) are
more common model used today
Logical Database
Design
Introduction to
Relational Data
Model
Two Major Strengths

• Simplicity

• Strong Mathematical Foundation


Relational Data Model
• Presented by E. F. Codd in 1970, then
of IBM
• Before Relational Data Model, two
older data models were in use;
Hierarchical, Network
Relational Data Model
• First DBMS built on Relational Data Model (RDM) was
system R
• Another Relational DBMS built during those days was
INGRES
Basic of RDM
RDM used mainly for external,
conceptual, and to some extent physical
schema
Separation of conceptual and physical
levels makes manipulation much easier,
contrary to previous data models
Basic of RDM
• RDM used for external, conceptual, and
to some extent physical schema
• The basic structure is relation
• Both entities and relationships are
modeled using tables/relations
Basics of RDM
• Relations physically represented as tables
• Table is a two dimensional representation of a relation
• Consists of rows and columns
Basics of RDM
• Columns represent attributes and rows represent
records
• Rows, records and tuples all these terms are used
interchangeably
Basic Properties of a
Table
1. Each cell of a table contains atomic/single value
2. Each column has a distinct name; the name of
the attribute it represents
Basic Properties of a Table
3. The values of the attributes come from the same domain
4. The order of the columns is immaterial
Basic Properties of a
Table
5. The order of the rows is immaterial
6. Each row/tuple/record is distinct, no two rows
can be same
A Table

Customer
Relation
RM Concept in DBMS
Attribute: Each column in a Table. Attributes are the
properties which define a relation. e.g.,
Student_Rollno, NAME,etc
Tables – In the Relational model the, relations are
saved in the table format. It is stored along with its
entities. A table has two properties rows and columns.
Rows represent records and columns represent
attributes.
Tuple – It is nothing but a single row of a table, which
contains a single record.
RM Concept in DBMS
Relation Schema: A relation schema represents the
name of the relation with its attributes.
Degree: The total number of attributes which in the
relation is called the degree of the relation.
Cardinality: Total number of rows present in the Table.
Column: The column represents the set of values for a
specific attribute.
Relation instance – Relation instance is a finite set of
tuples in the RDBMS system. Relation instances never
have duplicate tuples.
RM Concept in DBMS
Relation key – Every row has one, two or multiple
attributes, which is called relation key.
Attribute domain – Every attribute has some pre-
defined value and scope which is known as attribute
domain
Relational database schema – A set of relation
schemas ,each with a distinct name.
Example: If R1,R2,R3…..Rn are set of relations, then we
can write RDBMS as
R={ R1,R2,R3…..Rn}
Relational Integrity
Constraints
• Relational Integrity constraints in DBMS are referred to
conditions which must be present for a valid relation.
These Relational constraints in DBMS are derived from
the rules in the mini-world that the database represents.
• There are many types of Integrity Constraints in DBMS.
Constraints on the Relational database management
system is mostly divided into three main categories are:
1.Domain Constraints
2.Key Constraints
3.Referential Integrity Constraints
Create DOMAIN CustomerName CHECK (value not NULL)

Domain Constraints
• Domain constraints can be violated if an attribute
value is not appearing in the corresponding domain or
it is not of the appropriate data type.
• Domain constraints specify that within each tuple,
and the value of each attribute must be unique. This
is specified as data types which include standard data
types integers, real numbers, characters, Booleans,
variable length strings, etc.
Example:
create DOMAIN CustomerName
check( value not null)
Create DOMAIN CustomerName CHECK (value not NULL)

Key Constraints
• An attribute that can uniquely identify a tuple in a
relation is called the key of the table. The value of the
attribute for different tuples in the relation has to be
unique.
Example: In the given table, CustomerID is a key attribute of Customer Table.
It is most likely to have a single key for one customer, CustomerID =1 is only for the
CustomerName =” Google”.
Create DOMAIN CustomerName CHECK (value not NULL)

Referential Integrity
Constraints
• Referential Integrity constraints in DBMS are based on the concept of Foreign Keys.
A foreign key is an important attribute of a relation which should be referred to in
other relationships. Referential integrity constraint state happens where relation
refers to a key attribute of a different or same relation. However, that key element
must exist in the table.
• Example :

• In the above example, we have 2 relations, Customer and Billing.


• Tuple for CustomerID =1 is referenced twice in the relation Billing. So we know
CustomerName=Google has billing amount $300
Advantages of
Relational Database
• Model
Simplicity: A Relational data model in DBMS is simpler
than the hierarchical and network model.
• Easy to use: The Relational model in DBMS is easy as
tables consisting of rows and columns are quite natural
and simple to understand
• Data independence: The Structure of Relational database
can be changed without having to change any application.
Disadvantages of
Relational Model
• Relational databases can sometimes become complex as
the amount of data grows, and the relations between
pieces of data become more complicated.
• Complex relational database systems may lead to isolated
databases where the information cannot be shared from
one system to another.
Database
Management
System
Lecture – 03
END

You might also like