Professional Documents
Culture Documents
Mod 1
Mod 1
System)
RDBMS stands for Relational Database Management System.
All modern database management systems like SQL, MS SQL Server, IBM DB2, ORACLE, My-SQL, and
Microsoft Access are based on RDBMS.
It is called Relational Database Management System (RDBMS) because it is based on the relational model
introduced by E.F. Codd.
How it works
Data is represented in terms of tuples (rows) in RDBMS.
A relational database is the most commonly used database. It contains several tables, and each table has its
primary key.
Due to a collection of an organized set of tables, data can be accessed easily in RDBMS.
Properties of a Relation:
1 Ajeet 24 B.Tech
2 aryan 20 C.A
3 Mahesh 21 BCA
4 Ratan 22 MCA
5 Vimal 26 BSC
Properties of a row:
1 Ajeet 24 B.Tech
What is a column/attribute?
A column is a vertical entity in the table which contains all information associated with a specific field in a
table. For example, "name" is a column in the above table which contains all information about a student's
name.
Properties of an Attribute:
Name
Ajeet
Aryan
Mahesh
Ratan
Vimal
In the below example, the data item in the student table consists of Ajeet, 24 and Btech, etc.
1 Ajeet 24 B.Tech
Degree:
The total number of attributes that comprise a relation is known as the degree of the table.
For example, the student table has 4 attributes, and its degree is 4.
1 Ajeet 24 B.Tech
2 aryan 20 C.A
3 Mahesh 21 BCA
4 Ratan 22 MCA
5 Vimal 26 BSC
Cardinality:
In the context of a relational database, cardinality refers to the number of instances of one entity (table)
that can be related to the number of instances in another entity through a relationship. Cardinality is often
expressed as one-to-one (1:1), one-to-many (1:N), or many-to-many (N:M).
Entities:
1. Authors:
Attributes: AuthorID (Primary Key), AuthorName, Email
2. Books:
Attributes: BookID (Primary Key), Title, AuthorID (Foreign Key), PublicationYear
Relationship:
An author can write many books, but a book is typically written by one author. This is a one-to-many
relationship.
Cardinality:
Representation in Tables:
Explanation:
Jane Doe (AuthorID: 1) has written two books ("The Book of Life" and "Data Science Guide").
John Smith (AuthorID: 2) has written one book ("Programming 101").
In this example, the cardinality of the relationship between Authors and Books is one-to-many. One author
can be associated with multiple books, but each book is associated with only one author. This is a common
scenario in a database where an author writes multiple books, but each book is attributed to a single
author.
Domain:
The domain refers to the possible values each attribute can contain. It can be specified using standard data
types such as integers, floating numbers, etc. For example, An attribute entitled Marital_Status may be
limited to married or unmarried values.
NULL Values
The NULL value of the table specifies that the field has been left blank during record creation. It is different
from the value filled with zero or a field that contains space.
Data Integrity
Data integrity is a fundamental aspect of database management, ensuring that data is accurate, consistent, and
reliable throughout its lifecycle.
There are the following categories of data integrity exist with each RDBMS:
In this table:
This adherence to entity integrity ensures the uniqueness of each student in the Students table, and it
prevents any student from having a NULL value in the primary key column. In summary, entity integrity
ensures that each row in a table can be uniquely identified, and it helps maintain consistency and accuracy in the
database. Primary keys play a crucial role in enforcing entity integrity in relational databases.
Domain integrity: It enforces valid entries for a given column by restricting the type, the format, or the
range of values.
Now, let's focus on the Salary column and establish domain integrity for it.
Data Type: The Salary column should be of a numeric data type (e.g., INTEGER, DECIMAL).
Range: Salaries should be within a reasonable range. For example, they should not be negative.
Format: The format of salary values should follow a consistent pattern, such as being represented in whole
numbers or with a specific number of decimal places.
If domain integrity is enforced, the Employees table should not contain values that violate these rules. Let's
consider a scenario where domain integrity is not maintained:
Domain integrity in a relational database ensures that data values within a specific column or attribute
adhere to a defined set of permissible values, including data types, ranges, and formats. Let's consider an
example to illustrate domain integrity:
Referential integrity specifies that rows cannot be deleted, which are used by other records.
Referential integrity in a relational database ensures the consistency between related tables. It typically
involves the use of foreign keys to link rows in one table to rows in another. Let's consider an example to
illustrate referential integrity:
The AuthorID in the Books table is a foreign key that references the primary key AuthorID in the Authors
table.
This relationship ensures that every AuthorID in the Books table corresponds to a valid AuthorID in the
Authors table.
If referential integrity is maintained, all values in the AuthorID column of the Books table must exist in the
AuthorID column of the Authors table. Here's an example of maintaining referential integrity:
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, sorting etc.
There are the following differences between DBMS and File systems:
Meaning DBMS is a collection of data. In DBMS, the The file system is a collection of data. In
user is not required to write the this system, the user has to write the
procedures. procedures for managing the database.
Sharing of data Due to the centralized approach, data Data is distributed in many files, and it
sharing is easy. may be of different formats, so it isn't
easy to share data.
Data Abstraction DBMS gives an abstract view of data that The file system provides the detail of the
hides the details. data representation and storage of data.
Security and DBMS provides a good protection It isn't easy to protect a file under the file
Protection mechanism. system.
Recovery DBMS provides a crash recovery The file system doesn't have a crash
Mechanism mechanism, i.e., DBMS protects the user mechanism, i.e., if the system crashes
from system failure. while entering some data, then the
content of the file will be lost.
Manipulation DBMS contains a wide variety of The file system can't efficiently store and
Techniques sophisticated techniques to store and retrieve the data.
retrieve the data.
Concurrency DBMS takes care of Concurrent access of In the File system, concurrent access has
Problems data using some form of locking. many problems like redirecting the file
while deleting some information or
updating some information.
Where to use Database approach used in large systems File system approach used in large
which interrelate many files. systems which interrelate many files.
Cost The database system is expensive to The file system approach is cheaper to
design. design.
Data Redundancy Due to the centralization of the database, In this, the files and application
and Inconsistency the problems of data redundancy and programs are created by different
inconsistency are controlled. programmers so that there exists a lot of
duplication of data which may lead to
inconsistency.
Structure The database structure is complex to The file system approach has a simple
design. structure.
Data In this system, Data Independence exists, In the File system approach, there exists
Independence and it can be of two types. no Data Independence.
o Logical Data Independence
o Physical Data Independence
Integrity Integrity Constraints are easy to apply. Integrity Constraints are difficult to
Constraints implement in file system.
Data Models In the database approach, 3 types of data In the file system approach, there is no
models exist: concept of data models exists.
o Hierarchal data models
o Network data models
o Relational data models
Flexibility Changes are often a necessity to the The flexibility of the system is less as
content of the data stored in any system, compared to the DBMS approach.
and these changes are more easily with a
database approach.
DBMS Architecture
Data Models
Data Model is the modeling of the data description, data semantics, and consistency constraints of the
data. It provides the conceptual tools for describing the design of a database at each level of data
abstraction. Therefore, there are following four data models used for understanding the structure of the
database:
1) Relational Data Model: This type of model designs the data in the form of rows and columns within
a table. Thus, a relational model uses tables for representing data and in-between relationships.
Tables are also called relations. This model was initially described by Edgar F. Codd, in 1969. The
relational data model is the widely used model which is primarily used by commercial data
processing applications.
2) Entity-Relationship Data Model: An ER model is the logical representation of data as objects and
relationships among them. These objects are known as entities, and relationship is an association
among these entities. This model was designed by Peter Chen and published in 1976 papers. It was
widely used in database designing. A set of attributes describe the entities. For example,
student_name, student_id describes the 'student' entity. A set of the same type of entities is known
as an 'Entity set', and the set of the same type of relationships is known as 'relationship set'.
3) Object-based Data Model: An extension of the ER model with notions of functions, encapsulation,
and object identity, as well. This model supports a rich type system that includes structured and
collection types. Thus, in 1980s, various database systems following the object-oriented approach
were developed. Here, the objects are nothing but the data carrying its properties.
4) Semistructured Data Model: This type of data model is different from the other three data models
(explained above). The semistructured data model allows the data specifications at places where the
individual data items of the same type may have different attributes sets. The Extensible Markup
Language, also known as XML, is widely used for representing the semistructured data. Although
XML was initially designed for including the markup information to the text document, it gains
importance because of its application in the exchange of data.
DBMS Architecture
o The DBMS design depends upon its architecture. The basic client/server architecture is used to deal
with a large number of PCs, web servers, database servers and other components that are connected
with networks.
o The client/server architecture consists of many PCs and a workstation which are connected via the
network.
o DBMS architecture depends upon how users are connected to the database to get their request
done.
1-Tier Architecture
o In this architecture, the database is directly available to the user. It means the user can directly sit on
the DBMS and uses it.
o Any changes done here will directly be done on the database itself. It doesn't provide a handy tool
for end users.
o The 1-Tier architecture is used for development of the local application, where programmers can
directly communicate with the database for the quick response.
Let's consider a basic personal contact management system where users can store and retrieve contact
information.
1. Components:
User Interface: A simple desktop application that allows users to input, view, and manage their
contact information. The user interface is tightly integrated with the database.
Database Engine: A local database engine running on the same machine as the user interface. It
could be a lightweight embedded database like SQLite.
2. Architecture:
The entire application, including both the user interface and the database engine, runs on a single
computer (e.g., a personal computer).
Users interact with the application through the graphical user interface, which directly communicates
with the embedded database engine.
3. Characteristics:
Simplicity: This architecture is straightforward and easy to implement. There is no need for a
separate server or complex network configurations.
Limited Scalability: As the entire application runs on a single machine, it may face limitations in
terms of scalability. It's suitable for small-scale, personal use rather than large-scale enterprise
applications.
Easy Deployment: Since everything is contained on one machine, deployment is relatively simple.
Users can install the application on their computer without dealing with server setups.
2-Tier Architecture
o The 2-Tier architecture is same as basic client-server. In the two-tier architecture, applications on the
client end can directly communicate with the database at the server side. For this interaction, API's
like: ODBC, JDBC are used.
o The user interfaces and application programs are run on the client-side.
o The server side is responsible to provide the functionalities like: query processing and transaction
management.
o To communicate with the DBMS, client-side application establishes a connection with the server
side.
Let's consider a simple 2-tier architecture example for a basic online book inventory system:
1. Components:
Client (Frontend): A desktop application or web browser that allows users to interact with the
system. It handles the presentation logic and user input.
Server (Backend): A server-side application that manages the database, processes business logic,
and responds to client requests.
2. Architecture:
The client communicates with the server to perform operations such as adding a new book,
retrieving book information, or updating book details.
The server interacts with the database to store and retrieve book data.
3. Characteristics:
Separation of Concerns: The client and server components handle different aspects of the
application, allowing for better organization and maintenance.
Scalability: The server can be scaled independently of the client. For example, if the database load
increases, the server can be scaled up or distributed without affecting the client.
Concurrency: Multiple clients can simultaneously interact with the server, providing a more
responsive and efficient system.
Centralized Database: The database is typically hosted on a centralized server, allowing for better
data management and security.
3-Tier Architecture
o The 3-Tier architecture contains another layer between the client and server. In this architecture,
client can't directly communicate with the server.
o The application on the client-end interacts with an application server which further communicates
with the database system.
o End user has no idea about the existence of the database beyond the application server. The
database also has no idea about any other user beyond the application.
o The 3-Tier architecture is used in case of large web application.
Let's consider a real-world scenario for a 3-tier architecture: an online banking system.
1. Internal Level
o The internal level has an internal schema which describes the physical storage structure of the
database.
o The internal schema is also known as a physical schema.
o It uses the physical data model. It is used to define that how the data will be stored in a block.
o The physical level is used to describe complex low-level data structures in detail.
2. Conceptual Level
o The conceptual schema describes the design of a database at the conceptual level. Conceptual level
is also known as logical level.
o The conceptual schema describes the structure of the whole database.
o The conceptual level describes what data are to be stored in the database and also describes what
relationship exists among those data.
o In the conceptual level, internal details such as an implementation of the data structure are hidden.
o Programmers and database administrators work at this level.
3. External Level
o At the external level, a database contains several schemas that sometimes called as subschema. The
subschema is used to describe the different view of the database.
o An external schema is also known as view schema.
o Each view schema describes the database part that a particular user group is interested and hides
the remaining database from that user group.
o The view schema describes the end user interaction with database systems.
The Conceptual/ Internal Mapping lies between the conceptual level and the internal level. Its role is to define the
correspondence between the records and fields of the conceptual level and files and data structures of the internal
level.
The external/Conceptual Mapping lies between the external level and the Conceptual level. Its role is to
define the correspondence between a particular external and the conceptual view.
providedfor storing and accessing the database. The database design is implemented, populated
with actual data, andcontinuously maintained to reflect the state of the miniworld.