DBMS Unit-1
DBMS Unit-1
What is DBMS?
A Database Management System (DBMS) is a software system that is designed to manage and
organize data in a structured manner. It allows users to create, modify, and query a database, as
well as manage the security and access controls for that database. DBMS provides an
environment to store and retrieve data in convenient and efficient manner.
                                              (or)
The primary goal of a DBMS is to provide a way to store and retrieve database information that
is both convenient and efficient.
What is Database?
Data: Facts, figures, statistics etc. having no particular meaning (e.g. 1, ABC, 19 etc).
Record: Collection of related data items, e.g. in the above example the three data items had no
meaning. But
if we organize them in the following way, then they collectively represent meaningful
information.
1 ABC 19
1 ABC 19
2 DEF 20
3 GHI 22
Types of DBMS
Characteristics of DBMS
Some well-known characteristics are present in the DBMS (Database Management System).
These are explained below.
    o    The Database can store information such as the cost of vegetables, milk, bread, etc. In
         DBMS (Database Management System), the entities look like real-world entities.
    o    For example, if we want to create a student database, we need some entity. Any student
         stores their data.
    o    In the Database, then, it should be the real-world entity. The most commonly used
         properties in the student database are name, age, gender, roll number, etc.
2. Self-explaining nature
   o    Here, atomicity means either the operation should be performed or not performed. i.e., it
        should complete the operation on 0% or 100%.
   o    For example, every bank has its own Database, and the Database contains all the
        information about its customers. Let transaction is the most common atomic operation of
        the bank. If Sona wants to transfer 1000 rupees to the Archita account, it is possible with
        the help of the atomicity feature of the Database. If there is a problem in the Archita
        account, if there is a problem in the atomicity of the Database, then the money will be
        deducted from the Sona account but not credited to the Archita account.
   o    The Database has the feature of atomicity then; such transactions have not occurred at all,
        and if the transaction fails, then the money will automatically return to the sender
        account.
   o    Basically, for a successful transaction, the total operation depends on the Database. If the
        Database works perfectly, the transaction will be successful, and if the Database fails, the
        whole banking server will be down.
   o    Here the term anomalies mean multiuser can access the Database and fetch the
        information without any problem.
   o    For a better understanding, let's take the example of a bank again. Let Sonu give his
        ATM card to his sister Archita and tell her to withdraw 5000 from the ATM. At the same
        time, Sonu transferred 2000 rupees to his brother Monu. At the same time, both
        operations perform successfully. Initially, Sonu had 10000 rupees in his bank account.
        After both transactions, i.e., transfer and withdraw, when Sonu checks his bank balance,
        it shows 3000 rupees. This error-free updation of bank balance is possible with the help
        of the concurrent feature of the Database.
   o    The Database has the ability to store the data in a structured format.
   o    DBMS has the ability to store any type of data that exists in the real world, and these data
        are structured way. It is another type of very important characteristic of DBMS.
6. Integrity
   o    Here the term integrity means the data should be correct and consistent in nature. Let's
        understand this by taking an example.
   o    Let's say there is a bank named ABC bank, and ABC bank has its own Database for the
        storage of its customer data. If we try to enter the account details of ABC bank and the
        account details are not available in the bank, then the Database gives the incorrect output.
        However, if a customer changes their address but the new address is not updated in the
        Database, it is called data inconsistency.
   o    So the data available in the Database should be correct as well as consistent.
   o    The file and folder system was used to store the data before the DBMS came to the
        market.
   o    Searching for the student's name was a very difficult task at that time. This is because
        every search operation is done manually in the file and folder system. But when
        DBMS comes into the market, it is very easy to access the Database.
   o    In DBMS, we can search any kind of stored data by applying a simple search operation
        query. It is so much faster than manual searching.
   o    In DBMS, there is a CRUD operation ( here CRUD means Create, Read, Update &
        Delete) by which we can implement all the types of query in the Database.
   o    There are two types of databases (not DBMS): SQL and No-SQL.
   o    The SQL databases store the data in the form of Tables, i.e., rows and columns. The No-
        SQL databases can store data in any form other than a table. For instance: the very
        popular MongoDB stores the data in the form of JSON (JavaScript Object Notation).
   o    The availability of SQL and No-SQL databases allows us to choose the method of storing
        the data as well.
       Department of CSE ,NBKRIST                                           Prepared by Smt B.Rajani
9. ACID Properties
   o    The DBMS follows certain properties to maintain consistency in the Database. These
        properties are usually termed ACID Properties.
   o    ACID stands for Atomicity, Consistency, Isolation, and Durability.
   o    We have already talked about atomicity and consistency. Atomicity means the
        transaction should either be 0% or 100% completed, and consistency means that the
        change in data should be reflected everywhere in a database.
   o    Isolation means that multiple transactions can occur independently without the
        interference of some other transactions.
   o    Durability means that the chances of a successful atomic transaction, i.e., a transaction
        that has been 100% completed, should reflect in the Database.
10. Security
Difference between File System and DBMS(or) Database Systems versus File
Systems
• Data redundancy and inconsistency. Since different programmers create the files and
application programs over a long period, the various files are likely to have different formats and
the programs may be written in several programming languages. Moreover, the same information
may be duplicated in several places (files). For example, the address and telephone number of a
particular customer may appear in a file that consists of savings-account records
• Difficulty in accessing data. Suppose that one of the bank officers needs to find out the names
of all customers who live within a particular postal-code area. The officer asks the data-
processing department to generate such a list. Because the designers of the original system did
not anticipate this request, there is no application program on hand to meet it. There is, however,
an application program to generate the list of all customers. The bank officer has now two
choices: either obtain the list of all customers and extract the needed information manually or ask
a system programmer to write the necessary application program. Both alternatives are obviously
unsatisfactory. Suppose that such a program is written, and that, several days later, the same
officer needs to trim that list to include only those customers who have an account balance of
$10,000 or more. As expected, a program to generate such a list does not exist. Again, the officer
has the preceding two options, neither of which is satisfactory. The point here is that con
nventional file-processing environments do not allow needed data to be retrieved in a convenient
and efficient manner. More responsive data-retrieval systems are required for general use.
• Data isolation. Because data are scattered in various files, and files may be in different
formats, writing new application programs to retrieve the appropriate data is difficult.
• Integrity problems. The data values stored in the database must satisfy certain types of
consistency constraints. For example, the balance of a bank account may never fall below a
prescribed amount (say, $25). Developers enforce these constraints in the system by adding
appropriate code in the various application programs. However, when new constraints are added,
it is difficult to change the programs to enforce them. The problem is compounded when
constraints involve several data items from different files.
• Atomicity problems. A computer system, like any other mechanical or electrical device, is
subject to failure. In many applications, it is crucial that, if afailure occurs, the data be restored to
the consistent state that existed prior to the failure. Consider a program to transfer $50 from
account A to account B. If a system failure occurs during the execution of the program, it is
possible that the $50 was removed from account A but was not credited to account B, resulting in
an inconsistent database state. Clearly, it is essential to database consistency that either both the
credit and debit occur, or that neither occur. That is, the funds transfer must be atomic—it must
• Concurrent-access anomalies. For the sake of overall performance of the system and faster
response, many systems allow multiple users to update the data simultaneously. In such an
environment, interaction of concurrent updates may result in inconsistent data. Consider bank
account A, containing $500. If two customers withdraw funds (say $50 and $100 respectively)
from account A at about the same time, the result of the concurrent executions may leave the
account in an incorrect (or inconsistent) state. Suppose that the programs executing on behalf of
each withdrawal read the old balance, reduce that value by the amount being withdrawn, and
write the result back. If the two programs run concurrently, they may both read the value $500,
and write back $450 and $400, respectively. Depending on which one writes the values last, the
account may contain either $450 or $400, rather than the correct value of $350. To guard against
this possibility, the system must maintain some form of supervision. But supervision is difficult
to provide because data may be accessed by many different application programs that have not
been coordinated previously.
• Security problems. Not every user of the database system should be able to access all the data.
For example, in a banking system, payroll personnel need to see only that part of the database
that has information about the various bank employees. They do not need access to information
about customer accounts. But, since application programs are added to the system in an ad hoc
                                                                  In                    DBMS data
                                                                  independence exists, mainly of
                       There is no data independence.             two types:
Data                                                              1) Logical Data Independence .
Independence                                                      2)Physical Data Independence.
                       Only one user can access data at a         Multiple users can access data at a
User Access            time.                                      time.
                       The users are not required to write        The user has to write procedures
Meaning                procedures.                                for managing databases
Attributes             To access data in a file , user requires    No such attributes are required.
                         attributes such as file name, file
location.
Database Users
A Database User is defined as a person who interacts with data daily, updating, reading, and
modifying the given data. Database users can access and retrieve data from the database
through the Database Management System (DBMS) applications and interfaces.
Types of Database Users
Database users are categorized based on their interaction with the database. There are seven
types of database users in DBMS. Below mentioned are the types of database users:
A Database Administrator (DBA) is a person/team who defines the schema and also controls
the 3 levels of the database. The DBA will then create a new account ID and password for the
user if he/she needs to access the database. DBA is also responsible for providing security to
the database and he allows only authorized users to access/modify the database. DBA is
responsible for problems such as security breaches and poor system response time.
 DBA also monitors the recovery and backup and provides technical support.
 The DBA has a DBA account in the DBMS which is called a system or superuser account.
 DBA repairs damage caused due to hardware and/or software failures.
 DBA is the one having privileges to perform DCL (Data Control Language) operations
    such as GRANT and REVOKE, to allow/restrict a particular user from accessing the
    database.
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
example, Railway’s ticket booking users are naive users. Clerks in any bank is a naive user
because they don’t have any DBMS knowledge but they still use the database and perform
their given task.
3. A System Analyst
A system Analyst is a user who analyzes the requirements of parametric end users. They check
whether all the requirements of end users are satisfied.
4. 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.
     Department of CSE ,NBKRIST                                        Prepared by Smt B.Rajani
They don’t write the program code but they interact the database by writing SQL queries
directly through the query processor.
5. 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. He/she controls what data must be stored and
how the data items to be related. It is the responsibility of Database Designers to understand
the requirements of different user groups and then create a design which satisfies the need of
all the user groups.
6. Application Programmers
Application Programmers also referred as System Analysts or simply Software Engineers, are
the back-end programmers who writes the code for the application programs. They are the
computer professionals. These programs could be written in Programming languages such as
Visual Basic, Developer, C, FORTRAN, COBOL etc. Application programmers design, debug,
test, and maintain set of programs called “canned transactions” for the Naive (parametric) users
in order to interact with database.
Casual Users are the users who occasionally use/access the database but each time when they
access the database they require the new information, for example, Middle or higher level
manager.
8. Specialized users
Specialized users are sophisticated users who write specialized database application that does
not fit into the traditional data-processing framework. Among these applications are computer
aided-design systems, knowledge-base and expert systems etc.
Advantages of DBMS
In the File System, duplicate data is created in many places because all the programs have their
own files which create data redundancy resulting in wastage of memory. In DBMS, all the files
are integrated in a single database. So there is no chance of duplicate data.
For example: A student record in a library or examination can contain duplicate values, but when
they are converted into a single database, all the duplicate values are removed.
Data integrity makes unification of so many files into a single file. DBMS allows data integrity
which makes it easy to decrease data duplicity Data integration and reduces redundancy as well
as data inconsistency.
DBMS allows multiple users to access the same database at a time without any conflicts.
 Avoidance of inconsistency.
DBMS controls data redundancy and also controls data consistency. Data consistency is nothing
but if you want to update data in any files then all the files should not be updated again.
In DBMS, data is stored in a single database so data becomes more consistent in comparison to
file processing systems.
 Shared data
Data can be shared between authorized users of the database in DBMS. All the users have their
own right to access the database. Admin has complete access to the database. He has a right to
assign users to access the database.
 Enforcement of standards
As DBMS have central control of the database. So, a DBA can ensure that all the applications
follow some standards such as format of data, document standards etc. These standards help in
data migrations or in interchanging the data.
Unauthorized persons are not allowed to access the database because of security credentials.
Data loss is a big problem for all the organizations. In the file system users have to back up the
files in regular intervals which lead to waste of time and resources.
DBMS solves this problem of taking backup automatically and recovery of the database.
 Complexity
The provision of the functionality that is expected of a good DBMS makes the DBMS an
extremely complex piece of software. Database designers, developers, database administrators
and end-users must understand this functionality to take full advantage of it.
Failure to understand the system can lead to bad design decisions, which leads to a serious
consequence for an organization.
 Size
The functionality of DBMS makes use of a large piece of software which occupies megabytes of
disk space.
 Performance
The centralization of resources increases the vulnerability of the system because all users and
applications rely on the availability of DBMS, the failure of any component can bring operation
to halt.
 Cost of DBMS
The cost of DBMS varies significantly depending on the environment and functionality
provided. There is also the recurrent annual maintenance cost.
Database Applications
Nowadays, any business that has small or large amounts of data needs a database to store and
manage the information. The database is an easy, reliable, secure, and efficient way to maintain
business information. There are many applications where databases are used.
• Banking: For customer information, accounts, and loans, and banking transactions.
• Airlines: For reservations and schedule information. Airlines were among the first to use
databases in a geographically distributed manner—terminals situated around the world accessed
the central database system through phone lines and other data networks.
• Universities: For student information, course registrations, and grades.
       Department of CSE ,NBKRIST                                            Prepared by Smt B.Rajani
• Credit card transactions: For purchases on credit cards and generation of monthly statements.
• Telecommunication: For keeping records of calls made, generating monthly bills, maintaining
balances on prepaid calling cards, and storing information about he communication networks.
• Finance: For storing information about holdings, sales, and purchases of financial instruments
such as stocks and bonds.
• Sales: For customer, product, and purchase information.
• Manufacturing: For management of supply chain and for tracking production of items in
factories, inventories of items in warehouses/stores, and orders for items.
• Human resources: For information about employees, salaries, payroll taxes and benefits, and
for generation of paychecks.
Components of ER Model:
1. Entity: An entity is referred to as a real-world object. It can be a name, place, object, class,
   etc. These are represented by a rectangle in an ER Diagram.
2. Attributes: An attribute can be defined as the description of the entity. These are
   represented by Ellipse in an ER Diagram. It can be Age, Roll Number, or Marks for a
   Student.
3. Relationship: Relationships are used to define relations among different entities.
   Diamonds and Rhombus are used to show Relationships.
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. A popular representational model is
a Relational model. The relational Model consists of Relational Algebra and Relational
Calculus. In the Relational Model, we basically use tables to represent our data and the
relationships between them. It is a theoretical concept whose practical implementation is done
in Physical Data Model.
The advantage of using a Representational data model is to provide a foundation to form the
base for the Physical 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. It has all the
information on the format in which the files are present and the structure of the databases, the
presence of external data structures, and their relation to each other. Here, we basically save
tables in memory so they can be accessed efficiently. In order to come up with a good physical
model, we have to work on the relational model in a better way. Structured Query Language
(SQL) is used to practically implement Relational Algebra.
This Data Model describes HOW the system will be implemented using a specific DBMS
system. This model is typically created by DBA and developers. The purpose is actual
implementation of the database.
1. Hierarchical Model
The hierarchical Model is one of the oldest models in the data model which was developed by
IBM, in the 1950s. In a hierarchical model, data are viewed as a collection of tables, or we can
say segments that form a hierarchical relation. In this, the data is organized into a tree-like
structure where each record consists of one parent record and many children. Even if the
segments are connected as a chain-like structure by logical associations, then the instant
structure can be a fan structure with multiple branches. We call the illogical associations as
directional associations.
2. Network Model
The Network Model was formalized by the Database Task group in the 1960s. This model is
the generalization of the hierarchical model. This model can consist of multiple parent
segments and these segments are grouped as levels but there exists a logical association
between the segments belonging to any level. Mostly, there exists a many-to-many logical
association between any of the two segments.
In the Object-Oriented Data Model , data and their relationships are contained in a single
structure which is referred to as an object in this data model. In this, real-world problems are
represented as objects with different attributes. All objects have multiple relationships between
them. Basically, it is a combination of Object Oriented programming and a Relational
Database Model.
4. 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 can not be of large size.
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.
1.   In the case of a vast database, sometimes it becomes difficult to understand the data model.
2.   You must have the proper knowledge of SQL to use physical models.
3.   Even smaller change made in structure require modification in the entire application.
4.   There is no set data manipulation language in DBMS.
5.   To develop Data model one should know physical data stored characteristics.
Database Schema
    A database schema is a logical representation of data that shows how the data in a
     database should be stored logically. It shows how the data is organized and the relationship
     between the tables.
    Database schema contains table, field, views and relation between different keys
     like primary key, foreign key.
    Data are stored in the form of files which is unstructured in nature which makes accessing
     the data difficult. Thus to resolve the issue the data are organized in structured way with
     the help of database schema.
    Database schema provides the organization of data and the relationship between the stored
     data.
    Database schema defines a set of guidelines that control the database along with that it
     provides information about the way of accessing and modifying the data.
    A logical database schema defines all the logical constraints that need to be applied to the
     stored data, and also describes tables, views, entity relationships, and integrity constraints.
       Department of CSE ,NBKRIST                                           Prepared by Smt B.Rajani
   The Logical schema describes how the data is stored in the form of tables & how the
    attributes of a table are connected.
   Using ER modelling the relationship between the components of the data is maintained.
   In logical schema different integrity constraints are defined in order to maintain the quality
    of insertion and update the data.
   It is a view level design which is able to define the interaction between end-user and
    database.
   User is able to interact with the database with the help of the interface without knowing
    much about the stored mechanism of data in database.
DBMS Instance?
In DBMS, the data is stored for a particular amount of time and is called an instance of the
database. The database schema defines the attributes of the database in the particular DBMS. The
value of the particular attribute at a particular moment in time is known as an instance of the
DBMS.
For example, in the above example, we have taken the example of the attribute of the schema. In
this example, each table contains two rows or two records. In the above schema of the table, the
employee table has some instances because all the data stored by the table have some instances.
   Conceptual Level: At conceptual level, data is represented in the form of various database
    tables. For Example, STUDENT database may contain STUDENT and COURSE tables
    which will be visible to users but users are unaware of their storage.Also referred as logical
    schema,it describes what kind of data is to be stored in the database.
   External Level: An external level specifies a view of the data in terms of conceptual level
    tables. Each external level view is used to cater to the needs of a particular category of
    users. For Example, FACULTY of a university is interested in looking course details of
    students, STUDENTS are interested in looking at all details related to academics, accounts,
    courses and hostel details as well. So, different views can be generated for different users.
    The main focus of external level is data abstraction.
Data Independence
Data independence means a change of data at one level should not affect another level. Two
types of data independence are present in this architecture:
   Conceptual Data Independence: The data at conceptual level schema and external level
    schema must be independent. This means a change in conceptual schema should not affect
    external schema. e.g.; Adding or deleting attributes of a table should not affect the user’s
    view of the table. But this type of independence is difficult to achieve as compared to
    physical data independence because the changes in conceptual schema are reflected in the
    user’s view.
A Database Management System (DBMS) is software that allows users to define, store,
maintain, and manage data in a structured and efficient manner. It acts as an intermediary
between data and users, allowing disparate data from different applications to be managed. A
DBMS simplifies the complexity of data processing by providing tools to organize data, ensure
its integrity, and prevent unauthorized access or loss of data.
A Database Management System (DBMS) is software that allows users to define, store,
maintain, and manage data in a structured and efficient manner. It acts as an intermediary
between data and users, allowing disparate data from different applications to be managed.
DBMS simplifies the complexity of data processing by providing tools to organize data, ensure
its integrity, and prevent unauthorized access or loss of data.
   Hacking and exploiting: Attackers can use DBMS security gaps to access unauthorized
    sensitive data.
 Insider threats: Employees or contractors compromise privileged access to information.
 Phishing and social engineering: These are techniques that will trick the authorized user
    into revealing the login credentials to enable intrusion.
 Malware and ransomware attacks: These are malware that make database security
    vulnerable to attack, thus giving access to attackers to steal data or lock down data until
    some amount of ransom is paid.
Data theft prevention is not only an issue in sensitive information matters but also for building
trust between businesses and clients. Controls over access, periodic audits, real-time
monitoring of activities done through the database are effective measures one could consider to
reduce the risk. Also, following cyber security protocols and periodic inundation of database
systems will reduce most of the vulnerabilities.
Storage Manager
A storage manager is a program module that provides the interface between the lowlevel data
stored in the database and the application programs and queries submitted to the system. The
storage manager is responsible for the interaction with the file manager. The raw data are stored
on the disk using the file system, which is usually provided by a conventional operating system.
The storage manager translates the various DML statements into low-level file-system
commands. Thus, the storage manager is responsible for storing, retrieving, and updating data in
the database.
The storage manager components include:
• Authorization and integrity manager, which tests for the satisfaction of integrity constraints
and checks the authority of users to access data.
• Transaction manager, which ensures that the database remains in a consistent (correct) state
despite system failures, and that concurrent transaction executions proceed without conflicting.
• File manager, which manages the allocation of space on disk storage and the data structures
used to represent information stored on disk.
     Department of CSE ,NBKRIST                                          Prepared by Smt B.Rajani
• Buffer manager, which is responsible for fetching data from disk storage into main memory,
and deciding what data to cache in main memory. The buffer manager is a critical part of the
database system, since it enables the database to handle data sizes that are much larger than the
size of main memory. The storage manager implements several data structures as part of the
physical system implementation:
• Data files, which store the database itself.
• Data dictionary, which stores metadata about the structure of the database, in particular the
schema of the database.
• Indices, which provide fast access to data items that hold particular values
3. Disk Storage:
Architectures for DBMSs have generally followed trends seen in architectures for larger
computer systems. The primary processing for all system functions, including user application
programs, user interface programs, and all DBMS capabilities, was handled by mainframe
computers in earlier systems.
The primary cause of this was that the majority of users accessed such systems using computer
terminals with limited processing power and merely display capabilities. Only display data and
controls were delivered from the computer system to the display terminals, which were
connected to the central node by a variety of communications networks, while all processing was
done remotely on the computer system.
The majority of users switched from terminals to PCs and workstations as hardware prices
decreased. Initially, Database Systems operated on these computers in a manner akin to how they
had operated display terminals. As a result, the DBMS itself continued to operate as a centralized
DBMS, where all DBMS functionality, application program execution, and UI processing were
done on a single computer. The physical elements of a centralized architecture Client/server
DBMS designs emerged as DBMS systems gradually began to take advantage of the user side's
computing capability.
We first talk about client/server architecture in general, and then we look at how DBMSs use it.
In order to handle computing settings with a high number of PCs, workstations, file servers,
printers, database servers, etc., the client/server architecture was designed.
A network connects various pieces of software and hardware, including email and web server
software. To define specialized servers with a particular functionality is the aim. For instance, it
is feasible to link a number of PCs or compact workstations to a file server that manages the
client machines' files as clients. By having connections to numerous printers, different devices
can be designated as a printer server; all print requests from clients are then directed to this
machine. The category of specialized servers also includes web servers and email servers. Many
client machines can utilize the resources offered by specialized servers. The user is given the
proper user interfaces for these servers as well as local processing power to run local applications
on the client devices. This idea can be applied to various types of software, where specialist
applications, like a CAD (computer-aided design) package, are kept on particular server
computers and made available to a variety of clients. Some devices (such as workstations or PCs
with discs that only have client software installed) would only be client sites.
Here, the term "two-tier" refers to our architecture's two layers-the Client layer and the Data
layer. There are a number of client computers in the client layer that can contact the database
      Department of CSE ,NBKRIST                                           Prepared by Smt B.Rajani
server. The API on the client computer will use JDBC or some other method to link the
computer to the database server. This is due to the possibility of various physical locations for
clients and database servers.
The Business Logic Layer is an additional layer that serves as a link between the Client layer and
the Data layer in this instance. The layer where the application programs are processed is the
business logic layer, unlike a Two-tier architecture, where queries are performed in the database
server. Here, the application programs are processed in the application server itself.
Unit I-II
Introduction of ER Model
   o    ER model stands for an Entity-Relationship model. It is a high-level data model. This
        model is used to define the data elements and relationship for a specified system.
   o    It develops a conceptual design for the database. It also develops a very simple and easy
        to design view of data.
   o    In ER modeling, the database structure is portrayed as a diagram called an entity-
        relationship diagram.
For example, Suppose we design a school database. In this database, the student will be an
entity with attributes like address, name, id, age, etc. The address can be another entity with
attributes like city, street name, pin code, etc and there will be a relationship between them.
Component of ER Diagram
An entity may be any object, class, person or place. In the ER diagram, an entity can be
represented as rectangles.
1.Weak Entity
An entity that depends on another entity called a weak entity. The weak entity doesn't contain
any key attribute of its own. The weak entity is represented by a double rectangle.
2. Attribute
The attribute is used to describe the property of an entity. Eclipse is used to represent an
attribute.
For example, id, age, contact number, name, etc. can be attributes of a student.
The key attribute is used to represent the main characteristics of an entity. It represents a primary
key. The key attribute is represented by an ellipse with the text underlined.
b. Composite Attribute
An attribute that composed of many other attributes is known as a composite attribute. The
composite attribute is represented by an ellipse, and those ellipses are connected with an ellipse.
c. Multivalued Attribute
An attribute can have more than one value. These attributes are known as a multivalued attribute.
The double oval is used to represent multivalued attribute.
For example, a student can have more than one phone number.
An attribute that can be derived from other attribute is known as a derived attribute. It can be
represented by a dashed ellipse.
For example, A person's age changes over time and can be derived from another attribute like
Date of birth.
3. Relationship
A relationship is used to describe the relation between entities. Diamond or rhombus is used to
represent the relationship.
a. One-to-One Relationship
When only one instance of an entity is associated with the relationship, then it is known as one to
one relationship.
For example, A female can marry to one male, and a male can marry to one female.
When only one instance of the entity on the left, and more than one instance of an entity on the
right associates with the relationship then this is known as a one-to-many relationship.
For example, Scientist can invent many inventions, but the invention is done by the only
specific scientist.
c. Many-to-one relationship
When more than one instance of the entity on the left, and only one instance of an entity on the
right associates with the relationship then it is known as a many-to-one relationship.
For example, Student enrolls for only one course, but a course can have many students.
d. Many-to-many relationship
When more than one instance of the entity on the left, and more than one instance of an entity on
the right associates with the relationship then it is known as a many-to-many relationship.
For example, Employee can assign by many projects and project can have many employees.
Entity Set
An Entity is an object of Entity Type and a set of all entities is called an entity set. For Example,
E1 is an entity having Entity Type Student and the set of all students is called Entity Set. In ER
diagram, Entity Type is represented as:
We can represent the entity set in ER Diagram but can’t represent entity in ER Diagram because
entity is row and column in the relation and ER Diagram is graphical representation of data.
Types of Entity
There are two types of entity:
1. Strong Entity
A Strong Entity is a type of entity that has a key Attribute. Strong Entity does not depend on
other Entity in the Schema. It has a primary key, that helps in identifying it uniquely, and it is
represented by a rectangle. These are called Strong Entity Types.
2. Weak Entity
An Entity type has a key attribute that uniquely identifies each entity in the entity set. But some
entity type exists for which key attributes can’t be defined. These are called Weak Entity types .
For Example, A company may store the information of dependents (Parents, Children, Spouse)
of an Employee. But the dependents can’t exist without the employee. So Dependent will be
a Weak Entity Type and Employee will be Identifying Entity type for Dependent, which means
it is Strong Entity Type .
A weak entity type is represented by a Double Rectangle. The participation of weak entity types
is always total. The relationship between the weak entity type and its identifying strong entity
type is called identifying relationship and it is represented by a double diamond.
A Relationship Type represents the association between entity types. For example, ‘Enrolled in’
is a relationship type that exists between entity type Student and Course. In ER diagram, the
relationship type is represented by a diamond and connecting the entities with lines.
Entity-Relationship Set
Relationship Set
Unary Relationship
2. Binary Relationship: When there are TWO entities set participating in a relationship, the
relationship is called a binary relationship. For example, a Student is enrolled in a Course.
Binary Relationship
3. Ternary Relationship: When there are three entity sets participating in a relationship, the
relationship is called a ternary relationship.
4. N-ary Relationship: When there are n entities set participating in a relationship, the
relationship is called an n-ary relationship.
Constraints are used for modeling limitations on the relations between entities.
There are two types of constraints on the Entity Relationship (ER) model −
Mapping Cardinality
It is expressed as the number of entities to which another entity can be associated via a
relationship set.
For the binary relationship set there are entity set A and B then the mapping cardinality can be
one of the following −
       One-to-one
       One-to-many
       Many-to-one
       Many-to-many
One-to-one relationship
An entity set A is associated with at most one entity in B and an entity in B is associated with at
most one entity in A.
One-to-many relationship
An entity set A is associated with any number of entities in B with a possibility of zero and an
entity in B is associated with at most one entity in A.
Many-to-one relationship
Many-to-many relationship
An entity set A is associated with any number of entities in B with a possibility of zero and an
entity in B is associated with any number of entities in A with a possibility of zero.
Participation Constraints
       Total participation
       Partial Participation
Total participation
The participation of an entity set E in a relationship set R is said to be total if every entity in E
Participates in at least one relationship in R.
Partial Participation
Subclasses
A subclass is a class derived from the superclass. It inherits the properties of the superclass and
also contains attributes of its own. An example is:
Car, Truck and Motorcycle are all subclasses of the superclass Vehicle. They all inherit common
attributes from vehicle such as speed, colour etc. while they have different attributes also i.e
Number of wheels in Car is 4 while in Motorcycle is 2.
Super classes
A superclass is the class from which many subclasses can be created. The subclasses inherit the
characteristics of a superclass. The superclass is also known as the parent class or base class.
In the above example, Vehicle is the Superclass and its subclasses are Car, Truck and
Motorcycle.
Inheritance is basically the process of basing a class on another class i.e to build a class on a
existing class. The new class contains all the features and functionalities of the old class in
addition to its own.
The class which is newly created is known as the subclass or child class and the original class is
the parent class or the superclass.
Generalization
Generalization is the process of extracting common properties from a set of entities and
creating a generalized entity from it. It is a bottom-up approach in which two or more entities
can be generalized to a higher-level entity if they have some attributes in common. For
Example, STUDENT and FACULTY can be generalized to a higher-level entity called
PERSON as shown in Figure 1. In this case, common attributes like P_NAME, and P_ADD
become part of a higher entity (PERSON), and specialized attributes like S_FEE become part
of a specialized entity (STUDENT).
Generalization is also called as ‘ Bottom-up approach”.
Specialization
Inheritance: