Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

UNIT – 2

File System versus DBMS

A file system is a structure used by an operating system to organize and manage files on a
storage device such as a hard drive, solid state drive (SSD), or USB flash drive. It defines how
data is stored, accessed, and organized on the storage device.

Database Management Systems (DBMS) are software systems used to store, retrieve, and
run queries on data. A DBMS serves as an interface between an end-user and a database,
allowing users to create, read, update, and delete data in the database.

Basis File System DBMS


Structure The file system is a way of DBMS is software for
arranging the files in a managing the database.
storage medium within a
computer.
Data Redundancy Redundant data can be In DBMS there is no
present in a file system. redundant data.
Backup and Recovery It doesn’t provide Inbuilt It provides in house tools for
mechanism for backup and backup and recovery of data
recovery of data if it is lost. even if it is lost.
Query processing There is no efficient query Efficient query processing is
processing in the file system. there in DBMS.
Consistency There is less data consistency There is more data
in the file system. consistency because of the
process of normalization.
Structure of a DBMS

1. Query Processor: It interprets the requests (queries) received from end user via an
application program into instructions. It also executes the user request which is received
from the DML compiler.

Query Processor contains the following components –

 DML Compiler: It processes the DML statements into low level instruction (machine
language), so that they can be executed.
 DDL Interpreter: It processes the DDL statements into a set of table containing meta
data (data about data).
 Embedded DML Pre-compiler: It processes DML statements embedded in an application
program into procedural calls.
 Query Optimizer: It executes the instruction generated by DML Compiler.

2. Storage Manager: Storage Manager is a program that provides an interface between the
data stored in the database and the queries received. It is also known as Database Control
System. It maintains the consistency and integrity of the database by applying the
constraints and executing the DCL statements. It is responsible for updating, storing,
deleting, and retrieving data in the database.

It contains the following components –

 Authorization Manager: It ensures role-based access control, i.e,. checks whether the
particular person is privileged to perform the requested operation or not.
 Integrity Manager: It checks the integrity constraints when the database is modified.
 Transaction Manager: It controls concurrent access by performing the operations in a
scheduled way that it receives the transaction. Thus, it ensures that the database
remains in the consistent state before and after the execution of a transaction.
 File Manager: It manages the file space and the data structure used to represent
information in the database.
 Buffer Manager: It is responsible for cache memory and the transfer of data between
the secondary storage and main memory.

3. Disk Storage: It contains the following components –

 Data Files: It stores the data.


 Data Dictionary: It contains the information about the structure of any database object.
It is the repository of information that governs the metadata.
 Indices: It provides faster retrieval of data item.

The structure of a Database Management System (DBMS) can be divided into three main
components: the Internal Level, the Conceptual Level, and the External Level.

1. Internal Level: This level represents the physical storage of data in the database. It is
responsible for storing and retrieving data from the storage devices, such as hard drives
or solid-state drives. It deals with low-level implementation details such as data
compression, indexing, and storage allocation.
2. Conceptual Level: This level represents the logical view of the database. It deals with the
overall organization of data in the database and the relationships between them. It
defines the data schema, which includes tables, attributes, and their relationships. The
conceptual level is independent of any specific DBMS and can be implemented using
different DBMSs.
3. External Level: This level represents the user’s view of the database. It deals with how
users access the data in the database. It allows users to view data in a way that makes
sense to them, without worrying about the underlying implementation details. The
external level provides a set of views or interfaces to the database, which are tailored to
meet the needs of specific user groups.
People who deal with database

 Database Administrator (DBA) : Database Administrator (DBA) is a person/team who


defines the schema and also controls the 3 levels of database.

DBA is also responsible for providing security to the database and he allows only the
authorized users to access/modify the data base.

 Naive / Parametric End Users : Parametric End Users are the unsophisticated who don’t
have any DBMS knowledge but they frequently use the database applications in their
daily life to get the desired results. For examples, Railway’s ticket booking users are
naive users.
 System Analyst : System Analyst is a user who analyzes the requirements of parametric
end users. They check whether all the requirements of end users are satisfied.
 Sophisticated Users : Sophisticated users can be engineers, scientists, business analyst,
who are familiar with the database. They can develop their own database applications
according to their requirement.
 Database Designers : Data Base Designers are the users who design the structure of
database which includes tables, indexes, views, triggers, stored procedures and
constraints which are usually enforced before the database is created or populated with
data.

Introduction to Data Models

A Data Model in Database Management System (DBMS) is the concept of tools that are
developed to summarize the description of the database. Data Models provide us with a
transparent picture of data which helps us in creating an actual database. It shows us from
the design of the data to its proper implementation of data.

Types of Relational Models

 Conceptual Data Model


 Representational Data Model
 Physical Data Model

1. 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.
2. Representational Data Model

This type of data model is used to represent only the logical part of the database and does
not represent the physical structure of the database. The representational data model
allows us to focus primarily, on the design part of the database.

3. Physical Data Model

The physical Data Model is used to practically implement Relational Data Model.
Ultimately, all data in a database is stored physically on a secondary storage device such as
discs and tapes. This is stored in the form of files, records, and certain other data structures.

Concept of Normalization

Normalization is the process of organizing data in a database. It includes creating tables and
establishing relationships between those tables according to rules designed both to protect
the data and to make the database more flexible by eliminating redundancy and
inconsistent dependency.

Introduction to Entity Relationship model

The Entity Relational Model is a model for identifying entities to be represented in the
database and representation of how those entities are related. The ER data model specifies
enterprise schema that represents the overall logical structure of a database graphically.

The Entity Relationship Diagram explains the relationship among the entities present in the
database. ER models are used to model real-world objects like a person, a car, or a company
and the relation between these real-world objects. In short, the ER Diagram is the structural
format of the database.
Symbols used in ER model –

 Rectangles: Rectangles represent Entities in the ER Model.


 Ellipses: Ellipses represent Attributes in the ER Model.
 Diamond: Diamonds represent Relationships among Entities.
 Lines: Lines represent attributes to entities and entity sets with other relationship types.
 Double Ellipse: Double Ellipses represent Multi-Valued Attributes.
 Double Rectangle: Double Rectangle represents a Weak Entity.

Overview of Database Design

Database design is a collection of steps that help create, implement, and maintain a
business's data management systems. The primary purpose of designing a database is to
produce physical and logical models of designs for the proposed database system.

Entities, attributes and relationships

ER diagram –
Components of ER Diagram –

 Entity: An Entity may be an object with a physical existence – a particular person, car,
house, or employee – or it may be an object with a conceptual existence – a company, a
job, or a university course.
 Attributes: Attributes are the properties that define the entity type. For example,
Roll_No, Name, DOB, Age, Address, and Mobile_No are the attributes that define entity
type Student. In ER diagram, the attribute is represented by an oval.
 Relationship: The diamond shape showcases a relationship in the ER diagram. It depicts
the relationship between two entities. In the example below, both the student and the
course are entities, and study is the relationship between them.

Introduction to Relational Model

The relational model represents how data is stored in Relational Databases. A relational
database consists of a collection of tables, each of which is assigned a unique name.
Consider a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE, and AGE
shown in the table.

Table Student

ROLL_NO NAME ADDRESS PHONE AGE

1 RAM DELHI 9455123451 18

2 RAMESH GURGAON 9652431543 18

3 SUJIT ROHTAK 9156253131 20

4 SURESH DELHI 18
Integrity Constraints

 Integrity constraints are a set of rules. It is used to maintain the quality of information.
 Integrity constraints ensure that the data insertion, updating, and other processes have
to be performed in such a way that data integrity is not affected.
 Thus, integrity constraint is used to guard against accidental damage to the database.

Types of Integrity Constraint –

1. Domain constraints

 Domain constraints can be defined as the definition of a valid set of values for an
attribute.
 The data type of domain includes string, character, integer, time, date, currency, etc.
The value of the attribute must be available in the corresponding domain.

2. Entity integrity constraints

 The entity integrity constraint states that primary key value can't be null.
 This is because the primary key value is used to identify individual rows in relation and if
the primary key has a null value, then we can't identify those rows.
 A table can contain a null value other than the primary key field.

3. Referential Integrity Constraints

 A referential integrity constraint is specified between two tables.


 In the Referential integrity constraints, if a foreign key in Table 1 refers to the Primary
Key of Table 2, then every value of the Foreign Key in Table 1 must be null or be
available in Table 2.

4. Key constraints

 Keys are the entity set that is used to identify an entity within its entity set uniquely.
 An entity set can have multiple keys, but out of which one key will be the primary key. A
primary key can contain a unique and null value in the relational table.
Querying Relational Data using SQL

DDL and DML commands:

1. Data Definition Language (DDL) Data Definition Language (DDL) is a subset of SQL (Structured
Query Language) responsible for defining and managing the structure of databases and their objects.
DDL commands enable you to create, modify, and delete database objects like tables, indexes,
constraints, and more.

Key DDL Commands are-

 CREATE TABLE
 ALTER TABLE
 DROP TABLE
 TRUNCATE TABLE, etc.

2. Data Manipulation Language (DML) in SQL encompasses commands that manipulate data within a
database. DML allows you to insert, update, and delete records, ensuring the accuracy and currency
of your data

Following are the four main DML commands in SQL-

 SELECT Command : The SELECT statement is used to select data from a database.
 INSERT Command : The INSERT statement adds new records to a table
 UPDATE Command : The UPDATE statement modifies existing records in a table
 DELETE Command : The DELETE statement removes records from a table.

Aggregate Functions

These are used to perform calculations on groups of rows or entire result sets. They provide
insights into data by summarising and processing information.

Common Aggregate Functions -

 COUNT(): Counts the number of rows in a group or result set.


 SUM(): Calculates the sum of numeric values in a group or result set.
 AVG():Computes the average of numeric values in a group or result set.
 MAX(): Finds the maximum value in a group or result set.
 MIN(): Retrieves the minimum value in a group or result set.

You might also like