0% found this document useful (0 votes)
2 views9 pages

204 SQLUnit2

The document provides an overview of various data models used in database management systems, including the hierarchical, network, relational, and entity-relationship models. It explains key concepts such as attributes, keys (primary, foreign, candidate, unique, composite), and relationships, along with their types and mapping cardinalities. Additionally, it discusses the importance of keys in uniquely identifying records and establishing relationships between tables.

Uploaded by

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

204 SQLUnit2

The document provides an overview of various data models used in database management systems, including the hierarchical, network, relational, and entity-relationship models. It explains key concepts such as attributes, keys (primary, foreign, candidate, unique, composite), and relationships, along with their types and mapping cardinalities. Additionally, it discusses the importance of keys in uniquely identifying records and establishing relationships between tables.

Uploaded by

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

(CAM204-1C) Handling Data Using SQL

Unit 2: Data Model and Relational Algebra


1. Relational Model
2. Network model
3. Conceptual model
4. Hierarchical model
5. Entity Relationship model
5.1 Entity Types Entity sets, Attributes, and Keys (Super key, candidate key,
Primary key, Composite key, Foreign key, Unique key)
5.2 Notations for ER Diagrams
5.3 Types of Relationship (mapping cardinality
5.4 Designing example ER diagrams for requirements

Data Models
A Database model defines the logical design and structure of a database and defines
how data will be stored, accessed and updated in a database management system.
Models are,

 Hierarchical Model
 Network Model
 Entity-relationship Model
 Relational Model

Hierarchical Model

The hierarchical model is based on the parent-


child hierarchical relationship. In this model,
there is one parent entity with several children
entity. At the top, there should be only one
entity which is called root.
For example, an organization is the parent
entity called root and it has several children
entities like clerk, officer and many more. Data
is Stored Hierarchically (top down or bottom
up) format. Data is represented using a parent-
child relationship. Data and relationship among
data are represented by links. In Hierarchical
DBMS parent may have many children, but
children have only one parent.

Relational Model

The most popular and extensively used data model is the relational data model. The
data model allows the data to be stored in tables called relation.
The relations are normalized and the normalized relation values are known as atomic
values.
Each of the rows in a relation is called
tuples which contains the unique value.
The attributes are the values in each of the
columns which are of the same domain.
Relational DBMS is the most widely used
DBMS model because it is one of the
easiest. This model is based on
normalizing data in the rows and columns
of the tables. Relational model stored in
fixed structures and manipulated using
SQL.

Network Model

In the network data model, all the entities


are organized in graphical representations.
There may be several parts in the graph in
which the entities can be accessed. This is
an extension of the Hierarchical model. In
this model data is organized more like a
graph, and are allowed to have more than
one parent node.

Data in the network model are represented


by collection of records and relationship
among data are represented by links which can be viewed as pointer. The records in
the database are organized as collections of arbitrary graph.

Conceptual data model

The conceptual data model describes the database at a very high level and is useful
to understand the needs or requirements of the database. It is this model, that is used
in the requirement-gathering process i.e. before the Database Designers start making
a particular database.

Entity Relationship model

 ER model stands for an Entity-Relationship model.


 It is a high-level data model. This model is used to define the data elements
and relationship for a specified system.
 It develops a conceptual design for the database.
 It also develops a very simple and easy to design view of data.
E-R Diagram
• An ER diagram shows the relationship among entity sets.
• An entity set is a group of similar entities and these entities can have
attributes.
• In terms of DBMS, an entity is a table or attribute of a table in database,
• so by showing relationship among tables and their attributes, ER
diagram shows the complete logical structure of a database.
Symbols which are used in ER-Model

Weak Entity
An entity that depends on another entity called a weak entity. The weak entity
doesn't contain any key attribute of its own.
The weak entity is represented by a double rectangle.
strong entity
A strong entity is not dependent of any other entity in the schema. A strong
entity will always have a primary key. strong entities are represented by a single
rectangle
Attribute
The attribute is used to describe the property of an entity.
Eclipse is used to represent an attribute.
Attributes are also known as properties which define the entity type.
For example, Roll_No, Name, DOB, Age, Address, Mobile_No are the attributes
which defines entity type Student.

Types of an Attributes
1. Key Attribute Or single value Attribute
The attribute which uniquely identifies each
entity in the entity set is called key attribute.
For example, Roll_No will be unique for each
student. In ER diagram, key attribute is represented by an oval with
underlying lines.
2.Composite Attribute
An attribute composed of many other attribute is called as composite
attribute.
For example, Address attribute of
student Entity type consists of
Street, City, State, and Country.
In ER diagram, composite attribute
is represented by an oval
comprising of ovals.
3. Multivalued Attribute
An attribute consisting more than one
value for a given entity.
For example, Phone_No (can be more than one for a given student).
4. Derived Attribute
An attribute which can be derived from other
attributes of the entity type is known as derived
attribute.
e.g.; Age (can be derived from DOB).
In ER diagram, derived attribute is represented by dashed oval.
In ER diagram, multivalued attribute is represented by double oval.
Define relationship and relationship set AND types of relationship set.
Relationship is an association among 2 or more entities
Relationship set is a set of relationships of the same type.
Types of Relationship sets
Binary relationship set : Binary relationship set is a relationship set where two
entity sets participate in a relationship set.

Ternary relationship set : Ternary relationship set is a relationship set where three
entity sets participate in a relationship set.
Explain mapping cardinality.

A mapping cardinality is a data constraint that specifies how many entities an


entity can be related to in a relationship set.

A binary relationship set is a relationship set on two entity sets. Mapping


cardinalities on binary relationship sets are simplest.

Consider a binary relationship set R on entity sets A and B. There are four
possible mapping cardinalities in this case:

1. one-to-one - an entity in A is related to at most one entity in B, and an entity


in B is related to at most one entity in A.

2. one-to-many - an entity in A is related to any number of entities in B, but an


entity in B is related to at most one entity in A.
3. many-to-one - an entity in A is related to at most one entity in B, but an
entity in B is related to any number of entities in A.

4. many-to-many - an entity in A is related to any number of entities in B, but


an entity in B is related to any number of entities in A.

The mapping cardinality of a relationship set depends on the real world relationships
it is modeling.

Another kind of mapping constraints, called existence dependencies, occur when


the existence of an entity in an entity set depends on that entity being related to an
entity in another entity.
What is key? explain all types of key.
A DBMS key is an attribute or set of an attribute which helps you to identify a
row(tuple) in a relation(table). They allow you to find the relation between two
tables. Keys help you uniquely identify a row in a table by a combination of one or
more columns in that table.
Why we need a Key?

 Keys help you to identify any row of data in a table. In a real-world


application, a table could contain thousands of records. Moreover, the records
could be duplicated. Keys ensure that you can uniquely identify a table record
despite these challenges.
 Allows you to establish a relationship between and identify the relation
between tables
 Help you to enforce identity and integrity in the relationship.

Candidate Key: The minimal set of attribute which can uniquely identify a tuple
is known as candidate key. For Example, STUD_NO in STUDENT relation.

The value of Candidate Key is unique and non-null for every tuple.

There can be more than one candidate key in a relation. For Example, STUD_NO as
well as STUD_PHONE both are candidate keys for relation STUDENT.

The candidate key can be simple (having only one attribute) or composite as well.
For Example, {STUD_NO, COURSE_NO} is a composite candidate key for
relation STUDENT_COURSE.

Super Key: The set of attributes which can uniquely identify a tuple is known as
Super Key. For Example, STUD_NO, (STUD_NO, STUD_NAME) etc.

Adding zero or more attributes to candidate key generates super key.

A candidate key is a super key but vice versa is not true.

Primary Key: There can be more than one candidate key in a relation out of which
one can be chosen as primary key. For Example, STUD_NO as well as
STUD_PHONE both are candidate keys for relation STUDENT but STUD_NO can
be chosen as primary key (only one out of many candidate keys).

Alternate Key: The candidate key other than primary key is called as alternate
key. For Example, STUD_NO as well as STUD_PHONE both are candidate keys
for relation STUDENT but STUD_PHONE will be alternate key (only one out of
many candidate keys).

Foreign Key: If an attribute can only take the values which are present as values
of some other attribute, it will be foreign key to the attribute to which it refers. The
relation which is being referenced is called referenced relation and corresponding
attribute is called referenced attribute and the relation which refers to referenced
relation is called referencing relation and corresponding attribute is called
referencing attribute. Referenced attribute of referenced relation should be primary
key for it. For Example, STUD_NO in STUDENT_COURSE is a foreign key to
STUD_NO in STUDENT relation.
It may be worth noting that unlike, Primary Key of any given relation, Foreign Key
can be NULL as well as may contain duplicate tuples i.e. it need not follow
uniqueness constraint.

For Example, STUD_NO in STUDENT_COURSE relation is not unique. It has been


repeated for the first and third tuple. However, the STUD_NO in STUDENT relation
is a primary key and it needs to be always unique and it cannot be null.

Unique key.

A unique key is a set of one or more than one fields of a table that uniquely identify
a record in a database table.

it is like primary key but it can accept null value and it cannot have duplicate values.

What is the Composite key?

A key which has multiple attributes to uniquely identify rows in a table is called a
composite key. The difference between compound and the composite key is that any
part of the compound key can be a foreign key, but the composite key may or maybe
not a part of the foreign key.

Difference Between Primary key & Foreign key


Primary Key Foreign Key

Helps you to uniquely identify a It is a field in the table that is the primary
record in the table. key of another table.

Primary Key never accept null A foreign key may accept multiple null
values. values.

You can have the single Primary key You can have multiple foreign keys in a
in a table. table.

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