DBMS
DBMS
DATABASE ARCHITECTURE
Record:
A record in a Database Management System (DBMS) is a collection of related data fields that
represent a single entity or instance within a table.
Example: In a student table, a record might include fields like Name, Age, Height, Sem, Course. Each
row in the table is a record, such as: John, 18, 4.5, 2nd sem, BCA as shown below.
Table:
A table in a database is a collection of data organized into rows and columns. Each row represents a
single record, and each column represents a specific attribute of the data.
In this example:
Database:
A database is a collection of related data which represents some aspect of the real world.
A Database is a systematic collection of data.
pg. 1
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Note:
Charles Bachman, was an American Computer Scientist, He was particularly known for his
work in the early development of Database Management System (DBMS)
Edgar. F Codd was a English Computer Scientist , while working for IBM, invented
the Relational Database Management System (RDBMS)
History of DBMS:
1960 - Charles Bachman designed first DBMS system
1970 - Codd introduced IBM'S (International Business Machines) Information Management
System
1976 - Peter Chen coined and defined the Entity- relationship model
1980 - Relational Model becomes a widely accepted database.
1985 - Object-oriented DBMS develops.
1990s - Incorporation of object-orientation in relational DBMS.
pg. 2
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
File based systems were an early attempt to computerize the manual system. It is also called a
traditional based approach in which a decentralized approach was taken where each department stored
and controlled its own data with the help of a data processing specialist. The main role of a data
processing specialist was to create the necessary computer file structures, and also manage the data
within structures and design some application programs that create reports based on file data.
Consider an example of a student's file system. The student file will contain information regarding the
student (i.e. roll no, student name, course etc.). Similarly, we have a subject file that contains
information about the subject and the result file which contains the information regarding the result.
Some fields are duplicated in more than one file, which leads to data redundancy. So to overcome this
problem, we need to create a centralized system, i.e. DBMS approach.
DBMS:
A database approach is a well-organized collection of data that are related in a meaningful way which
can be accessed by different users but stored only once in a system. The various operations performed
by the DBMS system are: Insertion, deletion, selection, sort.
pg. 3
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
There are the following differences between DBMS and File systems:
pg. 4
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Sharing Data is distributed in many files. So, it Due to centralized nature data
is not easy to share data. sharing is easy
Data It give details of storage and It hides the internal details of
Abstraction representation of data Database
Integrity Integrity Constraints are difficult to Integrity constraints are easy to
Constraints implement implement
Attributes To access data in a file, user requires No such attributes are required.
attributes such as file name, file
location.
Example Cobol, C++ Oracle, SQL Server
Database Applications:
pg. 5
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
4. Education Sector
Presently, assessments are led online by numerous schools and colleges. They deal with all assessment
information through the data set administration framework (DBMS). In spite of that understudy’s
enlistments subtleties, grades, courses, expense, participation, results, and so forth all the data is put
away in the information base.
5. Credit card exchanges
The database Management framework is utilized for buying on charge cards and age of month to month
proclamations.
6. Social Media Sites
We all utilization of online media sites to associate with companions and to impart our perspectives to
the world. Every day, many people group pursue these online media accounts like Interest, Facebook,
Twitter, and Google in addition to. By the utilization of the data set administration framework, all the
data of clients are put away in the information base and, we become ready to interface with others.
7. Broadcast communications
Without DBMS any media transmission organization can’t think. The Database the executive’s
framework is fundamental for these organizations to store the call subtleties and month to month
postpaid bills in the information base.
8. Accounting and Finance
The information base administration framework is utilized for putting away data about deals, holding
and acquisition of monetary instruments, for example, stocks and bonds in a data set.
9. E-Commerce Websites
These days, web-based shopping has become a major pattern. Nobody needs to visit the shop and burn
through their time. Everybody needs to shop through web based shopping sites, (for example, Amazon,
Flipkart, Snapdeal) from home. So all the items are sold and added uniquely with the assistance of the
information base administration framework (DBMS). Receipt charges, installments, buy data these are
finished with the assistance of DBMS.
10. Human Resource Management
Big firms or organizations have numerous specialists or representatives working under them. They
store data about worker’s compensation, assessment, and work with the assistance of an information
base administration framework (DBMS).
pg. 6
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Characteristics of DBMS:
A DBMS ensures data security by restricting unauthorized access and allowing permissions
and roles. It also eliminates data redundancy by storing data in a single database and allowing
multiple applications to share the data, thus preventing duplication.
A DBMS includes a catalogue or dictionary that describes the structure of the database, such
as table definitions, schemas, constraints, and relationships. This metadata provides a
comprehensive overview of the database's organization and usage.
DBMS abstracts the data structure from the application programs, allowing changes to the
database structure without affecting the applications. This insulation ensures that programs do
not need to be rewritten if the database schema changes.
A DBMS allows different users to have customized views of the same database according to
their needs. These views can hide certain data or display data in a specific format, enhancing
security and usability.
pg. 7
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
In a DBMS, entities (real-world objects) and their relationships are modelled as tables. Each
table represents an entity, and relationships are established through foreign keys, enabling
complex queries and data integrity.
DBMS ensures reliable transactions through ACID properties. Atomicity guarantees complete
transactions, Consistency ensures data integrity, Isolation prevents transaction interference,
and Durability ensures permanence of committed transactions.
7. DBMS Supports Multi-User Environment that Allows Users to Access and Manipulate Data
in Parallel:
A DBMS enables concurrent data access and manipulation by multiple users without conflicts,
using locking mechanisms and transaction management to ensure data consistency and
isolation, supporting collaborative work environments.
Advantages of DBMS
1. Data Security: Provides controlled access to data, ensuring only authorized users can view or
modify data.
2. Data Integrity: Ensures accuracy and consistency of data through constraints and validation
rules.
3. Data Independence: Separates data structure from application programs, allowing changes
without affecting applications.
4. Data Redundancy Reduction: Minimizes duplicate data by storing data centrally.
5. Concurrent Access: Supports multiple users accessing data simultaneously without conflicts.
6. Backup and Recovery: Offers automated backup and recovery options to protect data from
loss.
7. Data Sharing: Facilitates data sharing among multiple users and applications.
8. Complex Query Support: Allows complex queries using SQL for advanced data retrieval and
manipulation.
9. Data Abstraction: Provides different views of data for different users, enhancing data
usability.
10. Transaction Management: Ensures reliable transactions with ACID properties.
Disadvantages of DBMS:
pg. 8
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
pg. 9
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Data Model:
Data models show that how the data is connected and stored in the system.
It shows the relationship between data.
A Model is basically a conceptualization between attributes and entities.
Types of Relational Models:
Conceptual Data Model
Representational Data Model
Physical Data Model
It is basically classified into 3 types:-
The representational data model, like the Relational Model, focuses on how data is organized logically
using tables to show relationships. It's about designing databases without worrying about how they're
physically stored. Relational Algebra and Calculus are theories that help in designing how data can be
managed and queried, while the actual storage details are handled in the Physical Data Model.
pg. 10
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Hierarchical Model: Data is structured like a tree with parent and child relationships.
Developed in the 1950s by IBM, it's organized into segments where each record has one parent
and many children, forming chains or fan-like structures.
Network Model: A generalization of the hierarchical model, formalized in the 1960s, it allows
multiple parent segments and many-to-many relationships between segments. Segments are
grouped into levels with logical associations, extending the hierarchical structure.
Object-Oriented Data Model: Combines object-oriented programming concepts with
databases. Data and relationships are represented as objects with attributes, reflecting real-
world entities. Objects can have multiple relationships between them, blending flexibility with
structured data storage.
Float Data Model: The float data model basically consists of a two-dimensional array of data
models that do not contain any duplicate elements in the array. This data model has one
drawback it cannot store a large amount of data that is the tables cannot be of large size.
Context Data Model: The Context data model is simply a data model which consists of more
than one data model. For example, the Context data model consists of ER Model, Object-
Oriented Data Model, etc. This model allows users to do more than one thing which each
individual data model can do.
Semi-Structured Data Model: Semi-Structured data models deal with the data in a flexible
way. Some entities may have extra attributes and some entities may have some missing
attributes. Basically, you can represent data here in a flexible way.
pg. 11
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Database Schema:
The database schema of a database is its structure described in a formal language supported by
the database management system (DBMS).
The term "schema" refers to the organization of data as a blueprint of how the database is
constructed (divided into database tables in the case of relational databases).
In the context of databases and DBMS, there are primarily three types of schemas:
1. Physical Schema:
o Defines how data is stored physically on a storage system such as disks or tapes. It
includes details like file structures, indexing methods, and data partitioning. This
schema is concerned with optimizing performance and storage efficiency.
2. Logical Schema:
o Describes the database structure at a conceptual level, focusing on how data is
represented and organized, independent of the specific DBMS implementation. It
includes tables, columns, relationships, and constraints, providing a high-level view of
the database.
pg. 12
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Not explicitly used in commercial DBMS products, but has been useful in explaining database system
organization
pg. 13
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
1. External level
It is also called view level. The reason this level is called “view” is because several users can view
their desired data from this level which is internally fetched from database with the help of conceptual
and internal level mapping.
External level is the “top level” of the Three Level DBMS Architecture.
2. Conceptual level
It is also called logical level. The whole design of the database such as relationship among data, schema
of data etc. are described in this level.
Database constraints and security are also implemented in this level of architecture. This level is
maintained by DBA (database administrator).
3. Internal level
This level is also known as physical level. This level describes how the data is actually stored in the
storage devices. This level is also responsible for allocating space to the data. This is the lowest level
of the architecture.
Data Independence:
The three-schema architecture can be used to explain the concept of data independence, which can be
defined as the capacity to change the schema at one level of a database system without having to
change the schema at the next higher level. We can define two types of data independence:
1. Logical data independence is the capacity to change the conceptual schema without having to
change external schemas or application programs. We may change the conceptual schema to expand
the database (by adding a record type or data item), or to reduce the database (by removing a record
type or data item).
2. Physical data independence is the capacity to change the internal schema without having to change
the conceptual (or external) schemas. Changes to the internal schema may be needed because some
physical files had to be reorganized—for example, by creating additional access structures—to
improve the performance of retrieval or update. If the same data as before remains in the database, we
should not have to change the conceptual schema.
pg. 14
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Database Language:
Databases are used to store information. The Database is related to both software and hardware here
The Software is used for accessing the data in the form of Software applications, and The Hardware is
used for storing the data in the memory or hard disk.
Any Database provides an interface between the end user and the database by using this interface, the
end user can access the database data. It is a very secure means before accessing database data we need
to authenticate first, and then we get access to the database. We have different types of Database
Languages which are represented in the below image.
Create
It is one the command in DDL which is used for creating objects in database means creating Tables,
Users, Triggers, functions and other objects. Here I will show how to create a table by using create
command from DDL.
pg. 15
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Syntax:
CREATE TABLE Students (
Column1 INT,
Column2 VARCHAR (50),
Column3 INT
);
Alter
It is one the command in DDL which is used for change or alter the structure of the database or table.
I already created students table with some columns you can see in the above image. Now by using
Alter command I add new column that weight to the students table.
Syntax:
ALTER TABLE Students ADD column_name;
Drop
This Drop command is used for delete objects from the database. In this example I drop the students
table
Syntax:
DROP Table Table_name;
Truncate
Truncate command is used for remove all records from a table. Now I remove rows from the Student
table.
Syntax:
TRUNCATE TABLE table_name;
Comment
It is used for comment on the data dictionary. We have two different comments namely Single line
comment and Multi-line comments.
Single Line
-- This is a single-line comment
pg. 16
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Multi-line comment
/*
This is a
Multi-line comment
*/
Rename
It is used to rename the object in database. Now I rename the table from students to Class Members.
Below I provide the example for better understanding.
Syntax:
ALTER TABLE Old_Table_Name RENAME TO New_Table_Name;
Grant
Basically the grant command is used for provide database access to the new user. Here I create one
user then I give the access to the database.
Syntax:
GRANT privileges
ON object
TO user_or_role [WITH GRANT OPTION];
Example:
GRANT SELECT, INSERT ON students TO user;
Revoke
The Revoke command is used to take back database access from the user. Now I provide the example
in the below
pg. 17
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Syntax:
REVOKE privileges ON object FROM user_or_role;
Example:
REVOKE ALL PRIVILEGES ON students FROM user;
Select
The Select command is used for select required data based on conditions from an existing Table. Here
I select all data from the ClassMembers Table.
Syntax:
SELECT * FROM Table_Name;
Insert
The Insert command is used for inserting new data into Table. Now I insert a new data into
ClassMembers Table. Below I provide the example.
Syntax:
INSERT INTO Table_Name (Column 1, Column 2, Column 3, Column 4) VALUES (Value 1, Value
2, Value 3, Value 4);
Update
The Update command is used for update information In the Table. Now I will update name John Doe
to Roman in the ClassMemebers Table. Below I provide that Example you can update any row or
columns data.
Syntax:
UPDATE Table_Name SET Name = 'New_Value' WHERE Name = 'Ola_Value';
Delete:
The Delete command is used for delete data from the Table. Here I delete Student Id with 2 from the
ClassMembers. Below I provide the Example for your reference.
pg. 18
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Syntax:
DELETE FROM Table_Name WHERE Column = Value;
Commit
The Commit command is used for save the transaction in the database and changes are made by the
DML statements. Now I will provide the example below Here I used ClassMembers Table. Here I
inserted a new data into Table then I commit it.
Syntax:
Commit;
ROLLBACK
Rollback command is used for restore the database to original state from last commit. Here I provide
the example and in this I already commit the you can see in the above, now I delete one row from the
Table then again rollback the previous database state.
Syntax:
ROLLBACK;
DBMS Interfaces:
DBMS Interfaces are the various methods through which users and applications interact with a
database management system. These interfaces facilitate the execution of operations such as querying,
updating, and managing the data stored within the database. The main types of DBMS interfaces
include:
Menu-Based Interfaces for Browsing
Forms-Based Interfaces
Graphical User Interfaces
Natural Language Interfaces
Interfaces for Parametric Users
Interfaces for the DBA
pg. 19
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Menu-Based Interfaces for Browsing: These interfaces present the user with lists of options,
called menus that lead the user through the formulation of a request. They are often used in
browsing interfaces, which allow a user to look through the contents of a database in an
exploratory and unstructured manner.
Forms-Based Interfaces: A forms-based interface displays a form to each user. Users can fill
out all of the form entries to insert new data, or they fill out only certain entries, in which case
the DBMS will retrieve matching data for the remaining entries.
Graphical User Interfaces: A graphical interface (GUI) typically displays a schema to the
user in diagrammatic form.
Natural Language Interfaces: These interfaces accept requests written in English or some
other language and attempt to "understand" them. A natural language interface usually has its
own "schema," which is similar to the database conceptual schema. The natural language
interface refers to the words in its schema, as well as to a set of standard words, to interpret the
request.
Interfaces for Parametric Users: Parametric users, such as bank tellers, often have a small
set of operations that they must perform repeatedly. Systems analysts and programmers design
and implement a special interface for a known class of naive users. Usually, a small set of
abbreviated commands is included, with the goal of minimizing the number of keystrokes
required for each request.
Interfaces for the DBA: Most database systems contain privileged commands that can be used
only by the DBA’s staff. These include commands for creating accounts, setting system
parameters, granting account authorization, changing a schema, and reorganizing the storage
structures of a database.
Classification of DBMS:
1) Centralized Database: It is the type of database that stores data at a centralized database system.
It comforts the users to access the stored data from different locations through several applications.
pg. 20
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
3) Relational Database: This database is based on the relational data model, which stores data in the
form of rows (tuple) and columns (attributes), and together forms a table (relation). A relational
database uses SQL for storing, manipulating, as well as maintaining the data.
pg. 21
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
4) NoSQL Database: Non-SQL/Not Only SQL is a type of database that is used for storing a wide
range of data sets. It is not a relational database as it stores data not only in tabular form but in several
different ways.
5) Cloud Database: A type of database where data is stored in a virtual environment and executes
over the cloud computing platform. It provides users with various cloud computing services (SaaS,
PaaS, IaaS, etc.) for accessing the database.
6) Object-oriented Databases: The type of database that uses the object-based data model approach
for storing data in the database system. The data is represented and stored as objects which are similar
to the objects used in the object-oriented programming language.
pg. 22
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
7) Hierarchical Databases: It is the type of database that stores data in the form of parent-children
relationship nodes. Here, it organizes data in a tree-like structure.
E-R Model:
Components of ER Model:
ER Model consists of Entities, Attributes, and Relationships among Entities in a Database System.
pg. 23
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Entity
An entity is an object in the real world with an independent existence and can be differentiated
from other objects
An entity might be
An object with physical existence. E.g. a lecturer, a student, a car.
An object with conceptual existence. E.g. a course, a job, a position.
Entity Type:
It refers to the category that a particular entity belongs to.
Example:
A table named student in a university database.
A table named employee in a company database.
Entity Set:
An Entity Set is a collection of entities of an entity type at a point of time.
Example:
The collection of all the students from the student table at a particular instant of time.
The collection of all the employees from the employee table at a particular instant of time.
pg. 24
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Types of attributes:
Simple attributes are attributes that are drawn from the atomic value domains
Example: Name = {John}; Age = {23}, also called Single valued.
Single-Valued Attribute: The attribute which takes up only a single value for each entity
instance is a single-valued attribute.
Example: The age of a student, Aadhar card number.
pg. 25
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Multivalued attributes: Attributes that have a set of values for each entity
Example: Degrees of a person: ‘BSc’, ‘MIT’, ‘PhD’
Derived attributes: Attributes contain values that are calculated from other attributes
Example: Age can be derived from attribute DateOfBirth. In this situation, DateOfBirth might
be called Stored Attribute.
Complex Attribute
Those attributes, which can be formed by the nesting of composite and multi-valued attributes, are
called “Complex Attributes“. These attributes are rarely used in DBMS (DataBase Management
System). That’s why they are not so popular.
Example: Address because address contain composite value like street, city, state, PIN code and also
multivalued because one people has more than one house address.
pg. 26
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Key attribute:
Key attributes are those attributes that can uniquely identify the entity in the entity set.
Example: Roll-No is the key attribute because it can uniquely identify the student.
Keys in DBMS:
Keys are one of the basic requirements of a relational database model. It is widely used to identify the
tuples (rows) uniquely in the table. We also use keys to set up relations amongst various columns and
tables of a relational database.
Different Types of Database Keys:
Primary Key-
A primary key is a candidate key that the database designer selects while designing the
database.
NOTES-
The value of primary key can never be NULL.
The value of primary key must always be unique.
The values of primary key can never be changed i.e. no updation is possible.
The value of primary key must be assigned when inserting a record.
A relation is allowed to have only one primary key.
pg. 27
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Foreign Key-
A foreign key is the one that is used to link two tables together via the primary key. It means
the columns of one table points to the primary key attribute of the other table.
It further means that if any attribute is set as a primary key attribute will work in another table
as a foreign key attribute.
Candidate Key-
A minimal super key is called as a candidate key.
OR
A set of minimal attribute(s) that can identify each tuple uniquely in the given relation is called
as a candidate key.
For example: In the EMPLOYEE table, id is best suited for the primary key. The rest of the
attributes, like SSN, Passport_Number, License_Number, etc., are considered a candidate key.
Super Key-
A super key is a set of attributes that can identify each tuple uniquely in the given relation.
A super key is not restricted to have any specific number of attributes.
Thus, a super key may consist of any number of attributes.
pg. 28
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
For example: In the above EMPLOYEE table, for (EMPLOEE_ID, EMPLOYEE_NAME), the name
of two employees can be the same, but their EMPLYEE_ID can't be the same. Hence, this combination
can also be a key.
Alternate Key-
Candidate keys that are left unimplemented or unused after implementing the primary key are
called as alternate keys.
OR
Unimplemented candidate keys are called as alternate keys.
For example, employee relation has two attributes, Employee_Id and PAN_No that act as
candidate keys. In this relation, Employee_Id is chosen as the primary key, so the other
candidate key, PAN_No, acts as the Alternate key.
Composite Key-
A primary key comprising of multiple attributes and not just a single attribute is called as a
composite key.
For example, in employee relations, we assume that an employee may be assigned multiple roles, and
an employee may work on multiple projects simultaneously. So the primary key will be composed of
all three attributes, namely Emp_ID, Emp_role, and Proj_ID in combination. So these attributes act as
a composite key since the primary key comprises more than one attribute.
pg. 29
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Secondary Key-
Secondary key is required for the indexing purpose for better and faster searching.
Unique Key-
Unique key is a key with the following properties-
It is unique for all the records of the table.
Once assigned, its value cannot be changed i.e. it is non-updatable.
It may have a NULL value.
Example-
The best example of unique key is Adhaar Card Numbers.
Partial Key-
Partial key is a key using which all the records of the table cannot be identified uniquely.
However, a bunch of related tuples can be selected from the table using the partial key.
Example-
Department ( Emp_no , Dependent_name , Relation )
Emp_no Dependent_name Relation
E1 Suman Mother
E1 Ajay Father
E2 Vijay Father
E2 Ankush Son
Here, using partial key Emp_no, we cannot identify a tuple uniquely but we can select a bunch
of tuples from the table.
pg. 30
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Surrogate Key-
Surrogate key is a key with the following properties-
It is unique for all the records of the table.
It is updatable.
It cannot be NULL i.e. it must have some value.
Example-
Mobile Number of students in a class where every student owns a mobile phone.
Domain of Attributes:
The set of possible values that an attribute can take is called the domain of the attribute. For example,
the attribute day may take any value from the set {Monday, Tuesday ... Friday}. Hence this set can be
termed as the domain of the attribute day.
pg. 31
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Many-to-Many Relationship
Such a relationship exists when each record of the first table can be related to one or more than
one record of the second table and a single record of the second table can be related to one or
more than one record of the first table.
The linking table links two tables by having fields which are the primary key of the other two
tables.
If there are two entity type ‘Customer’ and ‘Product’ then each customer can buy more than
one product and a product can be bought by many different customers.
pg. 32
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
There are numbers (represented by M and N) written above the lines which connect relationships and
entities. These are called cardinality ratios. These represent the maximum number of entities that can
be associated with each other through relationship, R.
One-to-one (1:1) – When one entity in each entity set takes part at most once in the relationship, the
cardinality is one-to-one.
One-to-many (1: N) – If entities in the first entity set take part in the relationship set at most once and
entities in the second entity set take part many times (at least twice), the cardinality is said to be one-
to-many.
pg. 33
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Many-to-one (N:1) – If entities in the first entity set take part in the relationship set many times (at
least twice), while entities in the second entity set take part at most once, the cardinality is said to be
many-to-one.
Many-to-many (N: N) – The cardinality is said to be many to many if entities in both the entity sets
take part many times (at least twice) in the relationship structural Constraints of Relationships in ER
Model
Consider two entities Employee and Department related via Works For relationship.
Now, every Employee works in at least one department therefore an Employee entity exist if it
has at least one Works For relationship with Department entity.
Thus the participation of Employee in Works For is total relationship.
Partial Participation
E ach entity in entity set may or may not occur in at least one relationship in a relationship set.
pg. 34
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Consider two entities Employee and Department and they are related to each other via Manages
relationship.
An Employee must manage a Department, he or she could be the head of the department.
But not every Employee in the company manages the department.
So, participation of employee in the Manages relationship type is partial i.e. only a particular
set of Employees will manage the Department but not all.
Structural Constraints:
Structural Constraints are also called Structural properties of a database management system
(DBMS). Cardinality Ratios and Participation Constraints taken together are called Structural
Constraints. The name constraints refer to the fact that such limitations must be imposed on the
data, for the DBMS system to be consistent with the requirements.
The Structural constraints are represented by Min-Max notation. This is a pair of numbers (m,
n) that appear on the connecting line between the entities and their relationships. The minimum
number of times an entity can appear in a relation is represented by m whereas, the maximum
time it is available is denoted by n. If m is 0 it signifies that the entity is participating in the
relation partially, whereas, if m is either greater than or equal to 1, it denotes total participation
of the entity. Note – Number of times an entity participates in a relationship is same as the
number appearance of the entity in the tuples.
pg. 35
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Degree of Relationship
The degree of a relationship is the number of entity types that participate (associate) in a relationship.
By seeing an E-R diagram, we can simply tell the degree of a relationship i.e. the number of an
entity type that is connected to a relationship is the degree of that relationship.
For example, if we have two entity type ‘Customer’ and ‘Account’ and they are linked using the
primary key and foreign key. We can say that the degree of relationship is 2 because here two entities
are taking part in the relationship.
Unary relationship
Binary relationship
Ternary relationship
N-ary relationship
Unary Relationship:
In this type of relationship, both the associating entity types are the same. So, we can say that unary
relationships exist when both entity types are the same and we call them the degree of relationship is
1. In other words, in a relation only one entity set is participating then such type of relationship is
known as a unary relationship.
Example: In a particular class, we have many students, there are monitors too. So, here class monitors
are also students. Thus, we can say that only students are participating here. So the degree of such type
of relationship is 1.
Binary Relationship:
In a Binary relationship, there are two types of entity associates. So, we can say that a Binary
relationship exists when there are two types of entity and we call them a degree of relationship is 2.
Or in other words, in a relation when two entity sets are participating then such type of relationship
is known as a binary relationship. This is the most used relationship and one can easily be converted
into a relational table.
pg. 36
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Example: We have two entity types ‘Student’ and ‘ID’ where each ‘Student’ has his ‘ID’. So, here
two entity types are associating we can say it is a binary relationship. Also, one ‘Father’ can have
many ‘daughters’ but each ‘daughter’ should belong to only one ‘father. We can say that it is a one-
to-many binary relationship.
Ternary (Degree 3)
In the Ternary relationship, there are three types of entity associates. So, we can say that a Ternary
relationship exists when there are three types of entity and we call them a degree of relationship is 3.
Since the number of entities increases due to this, it becomes very complex to turn E-R into a relational
table. Now let’s understand with the examples.
Example: We have three entity types ‘Teacher’, ‘Course’, and ‘Class’. The relationship between these
entities is defined as the teacher teaching a particular course, also the teacher teaches a particular class.
So, here three entity types are associating we can say it is a ternary relationship.
N-ary (n Degree)
In the N-ary relationship, there are n types of entity that associates. So, we can say that an N-ary
relationship exists when there are n types of entities. There is one limitation of the N-ary relationship,
as there are many entities so it is very hard to convert into an entity, rational table. So, this is very
uncommon, unlike binary which is very much popular.
Example: We have 5 entities Teacher, Class, Location, Salary, and Course. So, here five entity types
are associating we can say an n-ary relationship is 5.
pg. 37
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Entity type:
For example, a database of a corporate company has entity types such as employees, departments, etc.
In DBMS, every entity type contains a set of attributes that explain the entity.
The Employee entity type can have attributes such as name, age, address, phone number, and salary.
The Department entity type can have attributes such as name, number, and location in the department.
The entity relationship diagram represents a strong entity type with the help of a single rectangle.
Below is the ERD of the strong entity type:
In the above example, the "Customer" is the entity type with attributes such as ID, Name, Gender, and
Phone Number. Customer is a strong entity type as it has a unique ID for each customer.
It is an entity that does not have its own existence and relies on a strong entity for its existence.
The Entity Relationship Diagram represents the weak entity type using double rectangles. Below is
the ERD of the weak entity type:
pg. 38
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
In the above example, "Address" is a weak entity type with attributes such as House No., City,
Location, and State.
The relationship between a strong and a weak entity type is known as an identifying relationship.
Using a double diamond, the Entity-Relationship Diagram represents a relationship between the strong
and the weak entity type.
Let us see an example of the relationship between the Strong entity type and weak entity type with the
help of ER Diagram:
E-R Diagram:
ER diagrams are used to represent the E-R model in a database, which makes them easy to
convert into relations (tables).
ER diagrams provide the purpose of real-world modelling of objects which makes them intently
useful.
ER diagrams require no technical knowledge and no hardware support.
These diagrams are very easy to understand and easy to create even for a naive user.
It gives a standard solution for visualizing the data logically.
pg. 39
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
pg. 40
Chapter-1 Database Management System (DBMS)
DATABASE ARCHITECTURE
Employee works on project – One employee works on several projects and the number of
hours worked by the employee on a single project is recorded.
Employee has dependents – Each Employee has dependents. Each dependent is dependent
of only one employee.
pg. 41