0% found this document useful (0 votes)
139 views42 pages

22CS4201 DBMS UNIT 1 - Notesbbhjsjsjjsnsns

The document provides an overview of Database Management Systems (DBMS), including their purpose, architecture, advantages, and disadvantages. It discusses the differences between traditional file processing systems and DBMS, highlighting issues like data redundancy and inconsistency, while emphasizing the benefits of data independence and structured data management. Additionally, it covers data abstraction levels, schema types, and various data models, particularly the relational model, which simplifies data manipulation and retrieval.

Uploaded by

mohamedfahim2442
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
139 views42 pages

22CS4201 DBMS UNIT 1 - Notesbbhjsjsjjsnsns

The document provides an overview of Database Management Systems (DBMS), including their purpose, architecture, advantages, and disadvantages. It discusses the differences between traditional file processing systems and DBMS, highlighting issues like data redundancy and inconsistency, while emphasizing the benefits of data independence and structured data management. Additionally, it covers data abstraction levels, schema types, and various data models, particularly the relational model, which simplifies data manipulation and retrieval.

Uploaded by

mohamedfahim2442
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

22CS4201 - DATABASE MANAGEMENT SYSTEMS

UNIT – 1 INTRODUCTION TO DATABASES

Purpose of Database - Database System Architecture - Views of Data– Schema


architecture – Data Independence – Schema and instance- Data Models–
Benefits of Data Model – Phases of Data Model.ER Diagram - Extended ER
Diagram – Examples.

Introduction
• Definition: A Database Management System (DBMS) is a collection of
interrelated data and various programs that are used to handle that data.
• The primary goal of DBMS is to provide a way to store and retrieve the
required information from the database in convenient and efficient manner.
• For managing the data in the database two important tasks are conducted -
(i) Define the structure for storage of information.
(ii) Provide mechanism for manipulation of information.
• In addition, the database systems must ensure the safety of information stored.
Database System Applications
There are wide range of applications that make use of database systems. Some
of the applications are -
1) Accounting: Database systems are used in maintaining information
employees, salaries, and payroll taxes.
2) Manufacturing: For management of supply chain and tracking production of
items in factories database systems are maintained.
3) For maintaining customer, product and purchase information the databases
are used.
4) Banking: In banking sector, for customer information, accounts and loan and
for performing banking applications the DBMS is used.
5) For purchase on credit cards and generation of m`onthly statements database
systems are useful.
6) Universities: The database systems are used in universities for maintaining
student information, course registration, and accounting.
7) Reservation systems: In airline/railway reservation systems, the database is
used to at maintain the reservation and schedule information.
8) Telecommunication: In telecommunications for keeping records of the calls
made, generating monthly bills, maintaining balances on prepaid calling cards,
and storing information about communication networks the database systems
are used.
Purpose of Database System
• Earlier database systems are created in response to manage the commercial
data. These data is typically stored in files. To allow users to manipulate these
files various programs are written for
1) Addition of new data
2) Updating the data
3) Deleting the data.
• As per the addition of new need, separate application programs were required
to write. Thus as the time goes by, the system acquires more files and more
application programs.
• This typical file processing system is supported by conventional operating
system. Thus the file processing system can be described as -
• The system that stores the permanent records in files and it needs different
application programs to extract or add the records.
Before introducing database management system, this file processing system
was in use. However, such a system has many drawbacks. Let us discuss them
Disadvantages of Traditional File Processing System
The traditional file system has following disadvantages:
1) Data redundancy: Data redundancy means duplication of data at several
places. Since different programmers create different files and these files might
have different structures, there are chances that some information may appear
repeatedly in some or more format at several places.
2) Data inconsistency: Data inconsistency occurs when various copies of same
data may no longer get matched. For example changed address of an employee
may be reflected in one department and may not be available (or old address
present) for other department.
3) Difficulty in accessing data: The conventional file system does not allow to
retrieve the desired data in efficient and convenient manner.
4) Data isolation: As the data is scattered over several files and files may be in
different formats, it becomes to retrieve the desired data from the file for writing
the new application.
5) Integrity problems: Data integrity means data values entered in the database
fall within a specified range and are of correct format. With the use of several
files enforcing such constraint on the data becomes difficult.
6) Atomicity problems: An atomicity means particular operation must be
carried out sib entirely or not at all with the database. It is difficult to ensure
atomicity in conventional file processing system.
7) Concurrent access anomalies: For efficient execution, multiple users update
data simultaneously, in such a case data need to be synchronized. As in
traditional file systems, data is distributed over multiple files, one cannot access
these files concurrently.
8) Security problems: Every user is not allowed to access all the data of
database no system. Since application program in file system are added in an ad
hoc manner, enforcing such security constraints become difficult.
Database systems offer solutions to all the above mentioned problems.
Difference between Database System and Conventional File System

Characteristics of Database Systems


Following are the characteristics of database system
1) Representation of some aspects of real world applications.
2) Systematic management of information.
3) Representing the data by multiple views.
4) Efficient and easy implementation of various operations such as
insertion,deletion and updation.
5) It maintains data for some specific purpose.
6) It represents logical relationship between records and data.
Advantages of Database Systems
Following are the advantages of DBMS -
1) DBMS removes the data redundancy that means there is no duplication of
data in database, ends it
2) DBMS allows to retrieve the desired data in required format.
3) Data can be isolated in separate tables for convenient and efficient use.
4) Data can be accessed efficiently using a simple query language.
5) The data integrity can be maintained. That means - the constraints can be
applied on data and it should be in some specific range.
6) The atomicity of data can be maintained. That means, if some operation is
performed on one particular table of the database, then the change must be
reflected for the entire database.
7) The DBMS allows concurrent access to multiple users by using the
synchronization technique.
8) The security policies can be applied to DBMS to allow the user to access
only desired part of the database system.
Disadvantages of Database Systems
1) Complex design: Database design is complex, difficult and time consuming.
2) Hardware and software cost: Large amount of investment is needed to
setup the required hardware or to repair software failure.
3) Damaged part: If one part of database is corrupted or damaged, then entire
database may get affected.
4) Conversion cost: If the current system is in conventional file system and if
we need to convert it to database systems then large amount of cost is incurred
in purchasing different tools, and adopting different techniques as per the
requirement.
5) Training: For designing and maintaining the database systems, the people
need to be trained.

Database System Architecture work


• The typical structure of typical DBMS is based on relational data model as
shown in Fig 1.5.1.
• Consider the top part of Fig. 1.5.1. It shows application interfaces used by
naïve users, application programs created by application programmers, query
tools used by sophisticated users and administration tools used by database
administrator.
• The lowest part of the architecture is for disk storage.
• The two important components of database architecture are - Query processor
and storage manager.
Query processor:
• The interactive query processor helps the database system to simplify and
facilitate access to data. It consists of DDL interpreter, DML compiler and
query evaluation engine.
• With the following components of query processor, various functionalities are
performed -
i) DDL interpreter: This is basically a translator which interprets the DDL
statements in data dictionaries.
ii) DML compiler: It translates DML statements query language into an
evaluation plan. This plan consists of the instructions which query evaluation
engine understands.
iii) Query evaluation engine: It executes the low-level instructions generated
by the DML compiler.
• When a user issues a query, the parsed query is presented to a query optimizer,
which uses information about how the data is stored to produce an efficient
execution plan for evaluating the query. An execution plan is a blueprint for
evaluating a query. It is evaluated by query evaluation engine.
Storage manager:
• Storage manager is the component of database system that provides interface
between the low level data stored in the database and the application programs
and queries submitted to the system.
• The storage manager is responsible for storing, retrieving, and updating datain
the database. The storage manager components include -
i) Authorization and integrity manager: Validates the users who want to
access the data and tests for integrity constraints.
ii) Transaction manager: Ensures that the database remains in consistent
despite of system failures and concurrent transaction execution proceeds
without conflicting.
iii) File manager: Manages allocation of space on disk storage and
representation of the information on disk.
iv) Buffer manager: Manages the fetching of data from disk storage into main
memory. The buffer manager also decides what data to cache in main memory.
Buffer manager is a crucial part of database system.
• Storage manager implements several data structures such as -
i) Data files: Used for storing database itself.
ii) Data dictionary: Used for storing metadata, particularly schema of database.
iii) Indices: Indices are used to provide fast access to data items present in the
database

Views of Data
• Database is a collection of interrelated data and set of programs that allow
users to access or modify the data.
• Abstract view of the system is a view in which the system hides certain details
of how the data are stored and maintained.
• The main purpose of database systems is to provide users with abstract view of
the data.
• The view of the system helps the user to retrieve data efficiently.
• For simplifying the user interaction with the system there are several levels of
abstraction - these levels are - Physical level, logical level and view level.

Data Abstraction
Data abstraction: Data abstraction means retrieving only required amount of
information /of the system and hiding background details.
There are several levels of abstraction that simplify the user interactions with
the system. These are
1) Physical level:
• This is the lowest level.
• This level describes how actually the data are stored.
• This level describes complex low level data structures.
2) Logical level:
• This is the next higher level, which describes the what data are stored in
database.
• This level also describes the relationship among the data.
• The logical level thus describes then entire database in terms of small number
of relatively simple structures.
• The database administrators use logical level of abstraction for deciding what
information to keep in database.
3) View level:
This is highest level of abstraction that describes only part of the entire
database.
• The view level can provide the access to only part of the database.
• This level helps in simplifying the interaction with the system.
• The system can provide multiple views of the same system.
• Clerk at the reservation system, can see only part of the database and can
access the required information of the passenger.
Fig. 1.3.1 shows the relationship among the three levels of abstraction.

For example: Consider following record


Type employee = record
empID:numeric(10)
empname:char(20)
dept_no:numeric (10)
salary:numeric(8,2)
end
This code defines a new record employee with four fields. Each field is
associated with field name and its type. There are several other records such as
department with fields dept_no, dept_name, building
customer with fields cust_id,cust_name
• At the physical level, the record - customer, employee, department can be
Vibe described as block of consecutive storage locations. Many database
systems hide lowest level storage details from database programmer.
• The type definition of the records is decided at the logical level. The
programmer work of the record at this level, similarly database administrators
also work at this level of abstraction.
• There is specific view of the record is allowed at the view level. For instance -
- customer can view the name of the employee, or id of the employee but cannot
access employee's salary.
Three Schema Architecture
• Definition: Database schema is a collection of database objects like tables,
views, indexes and so on associated with one particular database username. This
username is called the schema owner.
• For example Student Schema can be owner of STUDENT and MARKS tables.
The Course schema can be the owner of SUBJECT table.
• The goal of three-schema architecture is to separate the user application from
the physical database.
• The architecture of database is divided into three levels based on three types of
schema - internal schema, conceptual schema or external schemea.

1. Internal level:
• It contains internal schema.
• This schema represents the physical storage structure of database.
• This schema is maintained by the software and user is not allowed to modify
it.
• This level is closest to the physical storage. It typically describes the record
layout of the files and types of files, access paths etc.
2. Conceptual level:
• It contains conceptual schema.
• This schema hides the details of internal level.
• This level is also called as logical level as it contains the constructs used for
designing the database.
• It contains information like table name, their columns, indexes and constraints,
database operations.
• A representational data model is used to describe conceptual schema when a
database system is implemented.
3. External level:
• It contains the external schema or user views.
• At this level, the user will get to see only the data stored in the database. Either
they will see whole data values or any specific records. They will not have any
information about how they are stored in the databases
• The processes of transforming requests and results between levels are called
mappings.
• In the three schema architecture there are two mappings -
1) External - Conceptual Mapping and
2) Conceptual - Internal Mapping.

Data Independence
Definition: Data independence is an ability by which one can change the data at
one level without affecting the data at another level. Here level can be physical,
conceptual or external.
Data independence is one of the important characteristics of database
management system.
By this property, the structure of the database or the values stored in the
database can be easily modified by without changing the application programs.
There are two types of data independence

1. Physical Independence: This is a kind of data independence which allows


the modification of physical schema without requiring any change to the
conceptual schema. For example - if there is any change in memory size of
database server then it will not affect the logical structure of any data object.
2. Logical Independence: This is a kind of data independence which allows the
modification of conceptual schema without requiring any change to the external
schema. For example - Any change in the table structure such as addition or
deletion of some column does not affect user views.
By these data independence the time and cost acquired by changes in any one
level can be reduced and abstract view of data can be provided to the user.

Instances and Schemas


Schema: The overall design of the database is called schema
For example - In a program we do variable declaration and assignment of values
to the variable. The variable declaration is called schema and the value assigned
to the variable is called instance. The schema for the student record can be

Instances: When information is inserted or deleted from the database then the
database gets changed. The collection of information at particular moment is
called instances. For example - following is an instance of student database

Types of Schema: The database has several schema based on the levels of
abstraction.
(1) Physical Schema: The physical schema is a database design described at the
physical level of abstraction.
(2) Logical Schema: The logical schema is a database design at the logical
level of abstraction.
(3) Subschema:A database may have several views at the view level which are
called subschemas.
Data Models
Definition: It is a collection of conceptual tools for describing data,
relationships among data, semantics (meaning) of data and constraints.
• Data model is a structure below the database.
• Data model provides a way to describe the design of database at physical,
logical and view level.
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 model:
• Relation model consists of collection of tables which stores data and also
represents the relationship among the data.
• Table is also known as relation.
• The table contains one or more columns and each column has unique name.
• Each table contains record of particular type, and each record type defines a
fixed number of fields or attributes.
• For example - Following figure shows the relational model by showing the
relationship between Student and Result database. For example - Student Ram
lives in city Chennai and his marks are 78. Thus the relationship between these
two databases is maintained by the SeatNo. Column

Advantages:
(i) Structural Independence: Structural independence is an ability that allows
us to make changes in one database structure without affecting other. The
relational levsiz model have structural independence. Hence making required
changes in thedatabase is convenient in relational database model.
(ii)Conceptual Simplicity: The relational model allows the designer to simply
focus on logical design and not on physical design. Hence relational models are
conceptually simple to understand.
(iii) Query Capability: Using simple query language (such as SQL) user can
get egile information from the database or designer can manipulate the database
structure.
(iv) Easy design,maintenance and usage: The relational models can be
designed logically hence they are easy to maintain and use.
Disadvantages:
(i) Relational model requires powerful hardware and large data storage devices.
(ii) May lead to slower processing time.
(iii) Poorly designed systems lead to poor implementation of database systems.
1) Entity relationship model:
• As the name suggests the entity relationship model uses collection of basic
objects called entities and relationships.
• The entity is a thing or object in the real world.
• The entity relationship model is widely used in database design.
• For example - Following is a representation of Entity Relationship modelin
which the relationship works_for is between entities Employee and
Department.

Advantages:
i) Simple: It is simple to draw ER diagram when we know entities and
relationships.
ii) Easy to understand: The design of ER diagram is very logical and hence
they are easy to design and understand.
iii) Effective: It is effective communication tool.
iv) Integrated: The ER model can be easily integrated with Relational model.
v) Easy conversion: ER model can be converted easily into other type of
models.
Disadvantages:
i) Loss of information: While drawing ER model some information can be
hidden or lost.
ii) Limited relationships: The ER model can represent limited relationships as
compared to other models.
iii) No Representation for data manipulation: It is not possible to represent
data manipulation in ER model.
iv) No industry standard: There is no industry standard for notations of ER
diagram.
(3) Object Based Data Model:
• The object oriented languages like C++, Java, C# are becoming the
dominant in software development.
• This led to object based data model.
• To The object based data model combines object oriented features with
relationaldata model.
Advantages:
i) Enriched modelling: The object based data model has capability of
modelling the real world objects.
ii) Reusability: There are certain features of object oriented design such as
inheritance, polymorphism which help in reusability.
iii) Support for schema evolution: There is a tight coupling between data and
b applications, hence there is strong support for schema evolution.
iv)Improved performance: Using object based data model there can be
significant improvement in performance using object based data model.
Disadvantages:
i) Lack of universal data model: There is no universally agreed data model for
an object based data model, and most models lack a theoretical foundation.
ii) Lack of experience: In comparison with relational database management the
use of object based data model is limited. This model is more dependent on the
skilled egi programmer.
iii) Complex: More functionalities present in object based data model make the
design complex.
(4) Semi-structured data model:
• The semi-structured data model permits the specification of data where
individual data items of same type may have different sets of attributes.
• The Extensible Markup Language (XML) is widely used to represent semi-
structured data model.
Advantages
i) Data is not constrained by fixed schema.
ii) It is flexible.
iii) It is portable.
Disadvantages
i) Queries are less efficient than other types of data model.

Benefits of Data Model

1. Higher Quality Applications


The most obvious benefit of data modelling is that it produces higher-
quality applications, which are less likely to crash and easier for you to
maintain.
2. Reduced Cost & Time of Application Development
Data modelling has a huge impact on the cost and time it takes to build a
new application. If your team does not have a data model, you will need to
spend time gathering requirements from users and hand-coding the database
structure.
3. Early Detection of Data Issues & Errors
In many cases, data issues and errors are not discovered until the process is
running. For example, a user might go to make a purchase and get an error
message saying “bad data.” In this scenario, the data was bad from the start.
You can test it in a lab or on a test server, but you don’t discover the errors
until the process is actually running in production.
4. Faster Application Performance
Data modeling isn’t just about saving money. That’s important, of course,
but the real value of data modeling is that it makes your application run
faster and more efficiently.
5. Better Documentation for long term maintenance
Data models help to define the business processes and their
interrelationships. If all the data related to a business process is defined in a
single place, it becomes easy to understand and maintain those processes
long-term.

ER Diagrams
An E-R diagram can express the overall logical structure of a database
graphically.E-R diagrams are used to model real-world objects like a person, a
car, a company and the relation between these real-world objects.
Features of ER model
i) E-R diagrams are used to represent E-R model in a database, which makes
them easy to be converted into relations (tables).
ii) E-R diagrams provide the purpose of real-world modeling of objects which
makes them intently useful.
iii) E-R diagrams require no technical knowledge and no hardware support.
iv) These diagrams are very easy to understand and easy to create even by a
naive user.
v) It gives a standard solution of visualizing the data logically.
Various Components used in ER Model are-
Mapping Cardinality Representation using ER Diagram
There are four types of relationships that are considered for key constraints.
i) One to one relation: When entity A is associated with at the most one entity
B then it shares one to one relation. For example - There is one project manager
who manages only one project.

ii) One to many :When entity A is associated with more than one entities at a
time then there is one to many relation. For example - One customer places
order at a time.

iii) Many to one : When more than one entities are associated with only one
entity then there is is many to one relation. For example – Many student take a
ComputerSciCourse

Alternate representation can be

iv) Many to many: When more than one entities are associated with more than
one entities. For example -Many teachers can teach many students.

Alternate representation can be

Ternary Relationship
The relationship in which three entities are involved is called ternary
relationship. For example -
Binary and Ternary Relationships
• Although binary relationships seem natural to most of us, in reality it is
sometimes necessary to connect three or more entities. If a relationship connects
three entities, it is called ternary or "3-ary."
• Ternary relationships are required when binary relationships are not sufficient
to accurately describe the semantics of an association among three entities.
• For example - Suppose, you have a database for a company that contains the
entities, PRODUCT, SUPPLIER, and CUSTOMER. The usual relationships
might be PRODUCT/ SUPPLIER where the company buys products from a
supplier - a normal binary relationship. The intersection attribute for
PRODUCT/SUPPLIER is wholesale_price

• Now consider the CUSTOMER entity, and that the customer buys products. If
all customers pay the same price for a product, regardless of supplier, then you
have a simple binary relationship between CUSTOMER and PRODUCT. For
the CUSTOMER/PRODUCT relationship, the intersection attribute is
retail_price.
• Single ternary relation: Now consider a different scenario. Suppose the
customer buys products but the price depends not only on the product, but also
on the supplier. Suppose you needed a customerID, a productID, and a
supplierID to identify a price. Now you have an attribute that depends on three
things and hence you have a relationship between three entities (a ternary
relationship) that will have the intersection attribute, price.

Weak Entity Set


• A weak entity is an entity that cannot be uniquely identified by its attributes
alone. The entity set which does not have sufficient attributes to form a primary
key is called as weak entity set.
• Strong Entity Set
The entity set that has primary key is called as strong entity set
Weak entity set because each player needs a team
Weak entity rules
• A weak entity set has one or more many-one relationships to other
(supporting) entity sets.
• The key for a weak entity set is its own underlined attributes and the keys for
the supporting entity sets. For example - player-number and team-name is a key
for Players.

Difference between Strong and Weak Entity Set

Enhanced ER Model
Specialization and Generalization
• Some entities have relationships that form hierarchies. For instance, Employee
can be an hourly employee or contracted employee.
• In this relationship hierarchies, some entities can act as superclass and some
other entities can act as subclass.
• Superclass: An entity type that represents a general concept at a high level, is
called superclass.
• Subclass: An entity type that represents a specific concept at lower levels, is
called subclass.
• The subclass is said to inherit from superclass. When a subclass inherits from
one or more superclasses, it inherits all their attributes. In addition to the
inherited attributes, a subclass can also define its own specific attributes.
• The process of making subclasses from a general concept is called
specialization. This is top-down process. In this process, the sub-groups are
identified within an entity set which have attributes that are not shared by all
entities.
• The process of making superclass from subclasses is called generalization.
This is a bottom up process. In this process multiple sets are synthesized into
high level entities.
• The symbol used for specialization/ Generalization is,

• For example - There can be two subclass entities namely Hourly_Emps and
Contract_Emps which are subclasses of Empoyee class. We might have
attributes hours_worked and hourly wage defined for Hourly_Emps and an
attribute contractid defined for ContractEmps.
Therefore, the attributes defined for an Hourly_Emps entity are the attributes for
Employees plus Hourly_Emps. We say that the attributes for the entity set
Employees are inherited by the entity set Hourly_Emps and that Hourly-Emps
ISA (read is a) Employees. It can be represented by following Fig. 2.4.1.
Constraints on Specialization/Generalization
There are four types of constraints on specialization/generalization relationship.
These are -
1) Membership constraints: This is a kind of constraints that involves
determining which entities can be members of a given lower-level entity. There
are two types of TO S membership constraints –
i) Condition defined: In condition-defined lower-level entity
sets,membership is evaluated on the basis of whether or not an entity satisfies an
explicit condition or predicate. For example - Consider the high-level entity Set
Employee that has attribute Employee_type. All Employee entities are
evaluated on defining Employee_type attribute. All entities that satisfy
the condition student type = "ContractEmployee" are included in Contracted
Employee. Since all the lower-level entities are evaluated on the basis of the
same attribute this type of generalization is said to be attribute-defined.
ii) User defined: This is kind of entity set that in which the membership
is manually defined.
2) Disjoint constraints: The disjoint constraint only applies when a superclass
has more than one subclass. If the subclasses are disjoint, then an entity
occurrence can be a member of only one of the subclasses. For entity Student
has either Postgraduate Student entity or Undergraduate Student

3) Overlapping: When some entity can be a member of more than one


subclasses. For example - Person can be both a Student or a Staff. The And can
be used to représent this constraint.

4) Completeness: It specifies whether or not an entity in the higher-level entity


set must belong to at least one of the lower-level entity sets within the
generalization/specialization. This constraint may be one of the following –
i) Total generalization or specialization: Each higher-level entity must
belong to a lower-level entity set. For example - Account in the bank must
either Savings account or Current Account. The mandatory can be used to
represent this constraint.
ii) Partial generalization or specialization: Some higher-level entities may
not belong to any lower-level entity set.

Aggregation
A feature of the entity relationship model that allows a relationship set to
participate in another relationship set. This is indicated on an ER diagram by
drawing a dashed box around the aggregation.
For example - We treat the relationship set work and the entity sets employee
and project as a higher-level entity set called work.
Examples based on ER Diagram
An E-R diagram can express the overall logical structure of a database
graphically.

Example 2.5.1 Draw the ER diagram for banking systems (home loan
applications).
OR Draw an ER diagram corresponding to customers and loans. AU: May.-14,
Marks 8
OR Write short notes on: E-R diagram for banking system. AU: Dec.-14,
Marks 8
Solution:
Example 2.5.2 Consider the relation schema given in Figure. Design and draw
an ER diagram that capture the information of this schema.AU: May-17, Marks
5
Employee(empno,name,office,age)
Books(isbn,title,authors,publisher)
Loan(empno,isbn,date)
Solution:
Example 2.5.3 Construct an E-R diagram for a car insurance company whose
customers own one or more cars each. Each car has associated with it zero to
any number of recorded accidents. Each insurance policy covers one or more
cars and has one or more premium payments associated with it. Each payment
is for particular period of time and has an associated due date and date when
the payment was received
Solution:

Example 2.5.4 A car rental company maintains a database for all vehicles in
its current fleet. For all vehicles, it includes the vehicle identification number
license number, manufacturer, model, date of purchase and color. Special data
are included for certain types of vehicles.
Trucks: Cargo capacity
Sports cars: horsepower, renter age requirement
Vans: number of passengers
Off-road vehicles: ground clearance, drivetrain (four-or two-wheel drive)
Construct an ER model for the car rental company database.
Solution:

Example 2.5.5 Draw E-R diagram for the "Restaurant Menu Ordering System",
which will facilitate the food items ordering and services within a restaurant.
The entire restaurant scenario is detailed as follows. The customer is able to
view the food items menu, call the waiter, place orders and obtain the final bill
through the computer kept in their table. The Waiters through their wireless
tablet PC are able to initialize a table for customers, control the table functions
to assist customers, orders, send orders to food preparation staff (chef) and
finalize the customer's bill. The Food preparation staffs (chefs), with their
touch-display interfaces to the system, are able to view orders sent to the
kitchen by waiters. Duringpreparation they are able to let the waiter know the
status of each item, and can send notifications when items are completed. The
system should have full accountability and logging facilities, and should
support supervisor actions to account for exceptional circumstances, such as a
meal being refunded or walked out on.
Solution:
Example 2.5.6 A university registrar's office maintains data about the
following entities:
(1) courses, including number, title, credits, syllabus, and prerequisites;
(2) course offerings, including course number, year, semester, section
number, instructor(s), timings, and classroom;
(3) students, including student-id, name, and program; and
(4) instructors, including identification number, name, department, and title.
Further, the enrollment of students in courses and grades awarded to students
in each course they are enrolled for must be appropriately modeled. Construct
an E-R diagram for the registrar's office. Document all assumptions that you
make about the mapping constraints.
Solution:
Example 2.5.7 What is aggregation in ER model? Develop an ER diagram
using aggregation that captures following information: Employees work for
projects. An employee working for particular project uses various machinery.
Assume necessary attributes. State any assumptions you make. Also discuss
about the ER diagram you have designed.
Solution Aggregation: Refer section 2.4.3.
ER Diagram: The ER diagram for above described scenario can be drawn as
follows-

The above ER model contains the redundant information, because every


Employee, Project, Machinery combination in works_on relationship is also
considered in manages relationship. To avoid this redundancy problem we can
make use of aggregation relationship in ER diagram as follows -

We can then create a binary relationship manages for between Manager and
(Employee, Project, Machinery).
Example 2.5.8 Construct an E-R diagram for a hospital with a set of patients
and a set of medical doctors. Associate with each patient a log of the various
tests and examinations conducted. AU: Dec.-07, Marks 8
Solution:

Example 2.5.9 Consider the following information about a university database:


i) Professors have an SSN, a name, an age, a rank and a research specialty.
ii) Projects have a project number, a sponsor name, (e.g. NSF), a starting date,
an ending date and a budget.
iii) Graduate students have an SSN, a name, an age and a degree program (e.g.
M.S. or Ph.D.).
iv) Each project is managed by one professor (known as the project's principal
investigators)
v) Each project is worked on by one or more professors (known as the project's
co- investigators).
vi) Professors can manage and/or work on multiple projects.
vii) Each project is worked on by one or more graduate students (known as the
project's research assistants).
viii) When graduate students work on a project, a professor must supervise
their work on the project. Graduate students can work on multiple projects, in
which case they will have a (potentially different) supervisor for each one.
ix) Departments have a department number, a department name and a main
office.
x) Departments have a professor (known as the chairman) who runs the
department.
xi) Professors work in one or more departments and for each department that
they work in, a time percentage is associated with their job,
xii) Graduate students have one major department in which they are working
on their degree.
xii) Each graduate student has another, more senior graduate student (known
as a student advisor) who advises him or her on what courses to take.
xiii) Design and draw an ER diagram that captures the information about the
university.
Use only the basic ER model here; that is entities, relationship and attributes.
Be sure to indicate any key and participation constraints.
Solution:
ER (Entity Relationship) Diagram in DBMS
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
1. Entity:
An entity may be any object, class, person or place. In the ER diagram, an
entity can be represented as rectangles.

Consider an organization as an example- manager, product, employee,


department etc. can be taken as an entity.

a. 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.

a. Key Attribute

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.
d. Derived Attribute

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.

Types of relationship are as follows:


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.

ADVERTISEMENT

ADVERTISEMENT

b. One-to-many relationship

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.

Notation of ER diagram
Database can be represented using the notations. In ER diagram, many
notations are used to express the cardinality. These notations are as
follows:
ER model is used to represent real life scenarios as entities. The properties of
these entities are their attributes in the ER diagram and their connections are
shown in the form of relationships.
Some examples of ER model are −

Hospital ER Model

This is an ER model of a Hospital. The entities are represented in rectangular


boxes and are Patient, Tests and Doctor.

Each of these entities have their respective attributes which are −

 Patients - ID(primary key), name, age,visit_date


 Tests- Name(primary key), date, result
 Doctor- ID(primary key), name, specialization

The relationships between different entities are represented by a diamond


shaped box.

Company ER Model
The entities in this ER model are Employee, Department and Project. These
entities have the following attributes −

 Employee - ENO(Primary Key) , Name, Salary


 Department - DNO(Primary key), Name, Locations
 Project - PNO(Primary key), Name

You might also like