Dbms Notes 4
Dbms Notes 4
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.
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.
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.
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
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.
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.
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
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