0% found this document useful (0 votes)
21 views41 pages

Dbmsmodels Updated1111111111

Uploaded by

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

Dbmsmodels Updated1111111111

Uploaded by

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

Database Model

• A Database model defines the logical


design of data. The model describes the
relationships between different parts of the
data.
Importance of Data Models
 Data models
 Representations, usually graphical, of complex
real-world data structures
 Facilitate interaction among the designer, the
applications programmer and the end user
 End-users have different views and needs
for data
 Data model organizes data for various users
The Importance of Data
Models
• Data models
– Relatively simple representations, usually
graphical, of complex real-world data
structures
– Facilitate interaction among the designer, the
applications programmer, and the end user

3
Commonly used data models
• Hierarchical Model
• Network Model
• Relational Model
• E-R Model
E-R Model
Basic Building Blocks
• Entity
– Anything about which data will be collected/stored
• Attribute
– Characteristic of an entity
• Relationship
– Describes an association among entities
• One-to-one (1:1) relationship
• One-to-many (1:M) relationship
• Many-to-many (M:N or M:M) relationship
• Constraint
– A restriction placed on the data
Entity Sets
• A database can be modeled as:
– a collection of entities,
– relationship among entities.

• An entity is an object that exists and is


distinguishable from other objects.
– Example: specific person, company, event, plant

• Entities have attributes


– Example: people have names and addresses

• An entity set is a set of entities of the same


type that share the same properties.
– Example: set of all persons, companies, trees, holidays
Attributes
• An entity is represented by a set of attributes, that is descriptive properties possessed by all members of an entity set.

• Domain – the set of permitted values for each attribute


• Attribute types:
– Simple and composite attributes.
– Single-valued and multi-valued attributes
• E.g. multivalued attribute: phone-numbers
– Derived attributes
• Can be computed from other attributes
• E.g. age, given date of birth

Example:
customer = (customer-id, customer-name,
customer-street, customer-city)
loan = (loan-number, amount)
Composite Attributes
Relationship Sets
 A relationship is an association among several entities

Example:
Hayes depositor A-102
customer entityrelationship setaccount entity
Degree of a Relationship Set
• Refers to number of entity sets that participate in a
relationship set.
• Relationship sets that involve two entity sets are binary
(or degree two). Generally, most relationship sets in a
database system are binary.
• Relationship sets may involve more than two entity
sets.
E.g. Suppose employees of a bank may have jobs
(responsibilities) at multiple branches, with different jobs at
different branches. Then there is a ternary relationship set
between entity sets employee, job and branch
Ternary Relationship
Mapping Cardinalities
• Express the number of entities to which another entity
can be associated via a relationship set.
• Most useful in describing binary relationship sets.
• For a binary relationship set the mapping cardinality
must be one of the following types:
– One to one
– One to many
– Many to one
– Many to many
Mapping Cardinalities

One to one One to many


Note: Some elements in A and B may not be mapped to any
elements in the other set
Mapping Cardinalities

Many to one Many to many


Note: Some elements in A and B may not be mapped to any
elements in the other set
E-R Diagrams

 Rectangles represent entity sets.


 Diamonds represent relationship sets.
 Lines link attributes to entity sets and entity sets to relationship sets.
 Ellipses represent attributes
 Double ellipses represent multivalued attributes.
 Dashed ellipses denote derived attributes.
 Underline indicates primary key attributes
Roles
• Entity sets of a relationship need not be
distinct
• The labels “manager” and “worker” are called roles; they specify how
employee entities interact via the works-for relationship set.
• Roles are indicated in E-R diagrams by labeling the lines that connect
diamonds to rectangles.
• Role labels are optional, and are used to clarify semantics of the relationship
Cardinality Constraints
• We express cardinality constraints by drawing either a
directed line (), signifying “one,” or an undirected line (—),
signifying “many,” between the relationship set and the
entity set.
• E.g.: One-to-one relationship:
– A customer is associated with at most one loan via the
relationship borrower
– A loan is associated with at most one customer via borrower
One-To-Many Relationship
• In the one-to-many relationship a loan is
associated with at most one customer via
borrower, a customer is associated with
several (including 0) loans via borrower
Many-To-Many Relationship

• A customer is associated with several (possibly 0)


loans via borrower
• A loan is associated with several (possibly 0)
customers via borrower
Many-To-One Relationships
• In a many-to-one relationship a loan is associated
with several (including 0) customers via borrower, a
customer is associated with at most one loan via
borrower
Hierarchical model
Hierarchical model
SALIENT FEATURES

• Logically represented by a TREE


• Each parent can have many children
• Each child has only one parent
• The top layer is perceived as the parent of the
segment directly beneath it.
• The segments below other segments are the children
of the segment above them.
The Hierarchical Model
• The hierarchical structure contains levels,
or segments
• Depicts a set of one-to-many (1:M)
relationships between a parent and its
children segments
– Each parent can have many children
– each child has only one parent

24
Hierarchical DB model
Advantages

• Conceptual simplicity

• Data independence

• Efficiency dealing with a large database


Disadvantages
• Complex implementation

• Difficult to manage and lack of standards

• Lacks structural independence

• Applications programming and use complexity

• Implementation limitations (no M:N relationship)


Network model
Network DB model
• The network model has greater flexibility than the hierarchical
model for handling complex spatial relationships
• Objective of network model is to separate data structure from
physical storage, eliminate unnecessary duplication of data with
associated errors and costs
• The Network Database Model was created for three main
purposes :
- representing a complex data relationship more
effectively
- improving database performance
- imposing a database standard
Network model
Key terms in network Model
• A node represents an object of interest.
• A link represents a relationship between two nodes. Within a
directed network, any link can be bidirected (that is, able to be
traversed either from the start node to the end node or from the
end node to the start node) or unidirected (that is, able to be
traversed only from the start node to the end node). Within an
undirected network, all links are bidirected.
• A path is an alternating sequence of nodes and links, beginning
and ending with nodes, and usually with no nodes and links
appearing more than once. (Repeating nodes and links within a
path are permitted, but are rare in most network applications.)
Advantages
• Simplicity : The network model is conceptually simple
and easy to design.
• Ability to handle more relationship types : The
network model can handle the one-to-many and many-
to-many relationships.
• Ease of data access : In the network database
terminology, a relationship is a set. Each set comprises
of two types of records.- an owner record and a member
record, In a network model an application can access an
owner record and all the member records within a set.
Relational model
Relational model
Relational DB model
• 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.
• 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.
• Relation instance − 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.
• Primary key − Each row has one or more attributes, known as
primary key, which can identify the row in the relation (table)
uniquely.
• Attribute domain − Every attribute has some pre-defined value
scope, known as attribute domain.
• Foreign key, often designated fk, is a common
column common between 2 tables that define the
relationship between those 2 tables.
• Foreign keys are either mandatory or optional.
Mandatory forces a child to have a parent by creating
a not null column at the child. Optional allows a child
to exist without a parent, allowing a nullable column
at the child table (not a common circumstance).
Terminology
Table name or relation name
Attribute names
Products:
Name Price Category Manufacturer

gizmo $19.99 gadgets GizmoWorks

Power gizmo $29.99 gadgets GizmoWorks

SingleTouch $149.99 photography Canon

MultiTouch $203.99 household Hitachi

Tuples or rows or records


Relation subject to the following rules
• Relation (file, table) is a two-dimensional table.
• Attribute (i.e. field or data item) is a column in the
table.
• Each column in the table has a unique name within
that table.
• Each column is homogeneous. Thus the entries in any
column are all of the same type (e.g. age, name,
employee-number, etc).
• Each column has a domain, the set of possible values
that can appear in that column.
• A Tuple (i.e. record) is a row in the table.
Relation subject to the following rules
• The order of the rows and columns is not important.
• Values of a row all relate to some thing or portion of a thing.
• Repeating groups (collections of logically related attributes
that occur multiple times within one record occurrence) are not
allowed.
• Duplicate rows are not allowed (candidate keys are designed to
prevent this).
• Cells must be single-valued (but can be variable length). Single
valued means the following:
– Cannot contain multiple values such as 'A1,B2,C3'.
– Cannot contain combined values such as 'ABC-XYZ' where
'ABC' means one thing and 'XYZ' another
Relational Integrity
Constraints
• Every relation has some conditions that must hold
for it to be a valid relation. These conditions are
called Relational Integrity Constraints. There
are two main integrity constraints −
• Entity Integrity constraint (Integrity Rule 1)
– It states that no attribute of a primary key can have a
null value
• Referential integrity constraints (Integrity Rule 2)
– It states that if a foreign key in table A refers to the
primary key of table B , then every value of foreign in
table A must be null or be available in table B.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy