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

Dbms Notes 4

The document discusses cardinality in Database Management Systems (DBMS), detailing the four types of cardinality mappings: one-to-one, many-to-one, one-to-many, and many-to-many. It also explains various data models including hierarchical, network, and relational data models, along with their advantages and disadvantages. Additionally, it covers Data Definition Language (DDL), Data Manipulation Language (DML), and Data Query Language (DQL) commands used in SQL for managing database structures and data.

Uploaded by

soumen.da.ace03
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)
7 views9 pages

Dbms Notes 4

The document discusses cardinality in Database Management Systems (DBMS), detailing the four types of cardinality mappings: one-to-one, many-to-one, one-to-many, and many-to-many. It also explains various data models including hierarchical, network, and relational data models, along with their advantages and disadvantages. Additionally, it covers Data Definition Language (DDL), Data Manipulation Language (DML), and Data Query Language (DQL) commands used in SQL for managing database structures and data.

Uploaded by

soumen.da.ace03
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

Cardinality in DBMS (Mapping Constraints)

Cardinality means how the entities are arranged to each other or what is the relationship
structure between entities in a relationship set. In a Database Management System,
Cardinality represents a number that denotes how many times an entity is participating
with another entity in a relationship set. The Cardinality of DBMS is a very important
attribute in representing the structure of a Database. In a table, the number of rows or
tuples represents the Cardinality.

There are four types of Cardinality Mapping in Database Management Systems:

1. One to one
2. Many to one
3. One to many
4. Many to many

One to one cardinality is represented by a 1:1 symbol. In this, there is at most one
relationship from one entity to another entity. There are a lot of examples of one-to-one
cardinality in real life databases.

For example, one student can have only one student id, and one student id can belong
to only one student. So, the relationship mapping between student and student id will be
one to one cardinality mapping.

Another example is the relationship between the director of the school and the school
because one school can have a maximum of one director, and one director can belong to
only one school.
Many to One Cardinality:
In many to one cardinality mapping, from set 1, there can be multiple sets that can make
relationships with a single entity of set 2. Or we can also describe it as from set 2, and one
entity can make a relationship with more than one entity of set 1.

One to one Cardinality is the subset of Many to one Cardinality. It can be represented
by M:1.

For example, there are multiple patients in a hospital who are served by a single doctor,
so the relationship between patients and doctors can be represented by Many to one
Cardinality.

One to Many Cardinalities:


In One-to-many cardinality mapping, from set 1, there can be a maximum single set that
can make relationships with a single or more than one entity of set 2. Or we can also
describe it as from set 2, more than one entity can make a relationship with only one entity
of set 1.

One to one cardinality is the subset of One-to-many Cardinality. It can be represented


by 1: M.

For Example, in a hospital, there can be various compounders, so the relationship


between the hospital and compounders can be mapped through One-to-many Cardinality.
Many to Many Cardinalities:
In many, many cardinalities mapping, there can be one or more than one entity that can
associate with one or more than one entity of set 2. In the same way from the end of set
2, one or more than one entity can make a relation with one or more than one entity of set
1.

It is represented by M: N or N: M.

One to one cardinality, One to many cardinalities, and Many to one cardinality is the subset
of the many to many cardinalities.

For Example, in a college, multiple students can work on a single project, and a single
student can also work on multiple projects. So, the relationship between the project and
the student can be represented by many to many cardinalities.
What is a Hierarchical Data Model?
The hierarchical data model is the oldest type of the data model. It was
developed by IBM in 1968. It organizes data in a tree-like structure.
Hierarchical model consists of the following:
 It contains nodes which are connected by branches.
 The topmost node is called the root node.
 If there are multiple nodes appear at the top level, then these can be
called root segments.
 Each node has exactly one parent.
 One parent may have many children.
In the above figure, Electronics is the root node which has two children i.e.
Televisions and Portable Electronics. These two has further children for
which they act as parent. For example: Television has children as Tube,
LCD and Plasma, for these three Television act as parent. It follows one
to many relationship.

Advantages of the Hierarchical Data Model

 Because of its tree form, it is easy to grasp.


 Retrieving data in a one-to-many connection is efficient.

Disadvantages of the Hierarchical Data Model

 Inflexibility in reorganizing data.


 Accessing complicated data structures may be challenging.
 Redundant data storage, which might cause anomalies and
inconsistencies.
What is a Network Data Model?

It is the advance version of the hierarchical data model. To organize data it


uses directed graphs instead of the tree-structure. In this child can have
more than one parent. It uses the concept of the two data structures i.e.
Records and Sets.

In the above figure, Project is the root node which has two children i.e.
Project 1 and Project 2. Project 1 has 3 children and Project 2 has 2
children. Total there are 5 children i.e Department A, Department B and
Department C, they are network related children as we said that this model
can have more than one parent. So, for the Department B and Department
C have two parents i.e. Project 1 and Project 2.
Advantages of the Network Data Model

 Because of its numerous parent ties, it is more adaptable than the


hierarchical approach.
 Ideal for managing intricate, many-to-many connections.

Disadvantages of the Network Data Model

 Increased complexity in database design and management.


 Requires complex programming in order to manage and work with
data.

What is a Relational Data Model?

The relational data model was developed by E.F. Codd in 1970. There are
no physical links as they are in the hierarchical data model. Following are
the properties of the relational data model:
 Data is represented in the form of table only.
 It deals only with the data not with the physical structure.
 It provides information regarding metadata.
 At the intersection of row and column there will be only one value for
the tuple.
 It provides a way to handle the queries with ease.

Advantages of the Relational Data Model


 High data independence and flexibility.
 Offers robust and user-friendly querying features.
 Removes duplication by use of normalization.

Disadvantages of the Relational Data Model

 For certain kinds of straightforward data retrieval tasks, they may not
perform as well as hierarchical models.
 Demands a deeper comprehension of SQL and normalization
principles.

DDL (Data Definition Language):

DDL or Data Definition Language actually consists of the SQL commands


that can be used to define the database schema. It simply deals with
descriptions of the database schema and is used to create and modify the
structure of database objects in the database.
DDL is a set of SQL commands used to create, modify, and delete
database structures but not data. These commands are normally not used
by a general user, who should be accessing the database via an
application.
List of DDL Commands:
Here are all the main DDL (Data Definition Language) commands along
with their syntax:

Command Description Syntax

Create database or its


CREATE TABLE table_name
objects (table, index, (column1 data_type, column2
CREATE
function, views, store data_type, ...);
procedure, and triggers)

Delete objects from the DROP TABLE table_name;


DROP
database

ALTER TABLE table_name ADD


Alter the structure of the COLUMN column_name
ALTER
database data_type;

Remove all records from TRUNCATE TABLE table_name;


TRUNCATE
a table, including all
Command Description Syntax

spaces allocated for the


records are removed

Add comments to the COMMENT 'comment_text' ON


COMMENT TABLE table_name;
data dictionary

Rename an object RENAME TABLE old_table_name


RENAME TO new_table_name;
existing in the database

DML (Data Manipulation Language):


The SQL commands that deal with the manipulation of data present in the
database belong to DML or Data Manipulation Language and this includes
most of the SQL statements.
List of DML commands
Here are all the main DML (Data Manipulation Language) commands
along with their syntax:
Command Description Syntax

INSERT INTO table_name (column1,


Insert data into a column2, ...) VALUES (value1, value2,
INSERT
table ...);

Update existing
UPDATE table_name SET column1 = value1,
UPDATE data within a column2 = value2 WHERE condition;
table

Delete records
DELETE from a database DELETE FROM table_name WHERE condition;
table

Table control LOCK TABLE table_name IN lock_mode;


LOCK
concurrency

Call a PL/SQL or
CALL JAVA CALL procedure_name(arguments);
subprogram
Command Description Syntax

Describe the
EXPLAIN EXPLAIN PLAN FOR SELECT * FROM
access path to table_name;
PLAN
data

DQL (Data Query Language):


DQL statements are used for performing queries on the data within schema
objects. The purpose of the DQL Command is to get some schema relation
based on the query passed to it
When a SELECT is fired against a table or tables the result is compiled into
a further temporary table, which is displayed or perhaps received by the
program i.e. a front-end.
DQL Command
There is only one DQL command in SQL i.e.
Command Description Syntax

SELECT column1, column2,


It is used to retrieve data ...FROM table_name WHERE
SELECT
from the database condition;

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