You are on page 1of 87

Introduction to

Database Management
System
UNIT 1
Introduction to dbms
Data - unprocessed information
- raw facts/ figures.
Information- Processed Data.
Data is converted into information, and information is
converted into knowledge.
DBMS
Database Management System is a collection
of interrelated data and a set of programs to access those
data.
The examples of DBMS are MS-ACCESS, ORACLE, SQL
SERVER etc.
Database Applications:-
◦ Banking: transactions
◦ Airlines: reservations, schedules
◦ Universities: registration, grades
◦ Sales: customers, products, purchases
◦ Online retailers: order tracking, customized
recommendations
◦ Manufacturing: production, inventory, orders etc.
◦ Human resources: employee records, salaries, tax
deductions
Goals of Database Management
System

(1) To remove problem of data redundancy and


inconsistency- 
Information about same person(or anything) may be stored in
different files because different peoples are accessing it. So it
may leads to Data Redundancy . Data Redundancy means
Data Duplication.
Data Inconsistency means various copies of same data may
no longer agree. For eg: Changed customer address may be
reflected in savings account records but not elsewhere in the
system.
(2) Easy access of data-
If a bank officer needs to find account details names of all
customer who live within a particular postal- code or having
same name, but it may take longer time to check all accounts
having savings account in that particular bank.
But using Database Management System data can be retrieved
in a convenient and efficient manner.
(3) To solve Data Isolation problem- As data are scattered in
various files, and files may be in various formats, writing new
application programs to retrieve the appropriate data is difficult.
(4) To solve Atomicity problem- A computer system may fail. In
many applications it is crucial that, if a failure occurs the data be
restored to the consistent state that existed prior to the failure.
E.g. let us having a program to transfer $ 50 from account A to
account B. If a system failure occur during the execution of
program, it is possible that the $ 50 was removed from account A
bit was not clearly it is essential to data consistency that either both
the credit and debit occur or that neither occur. That is fund
transfer must be atomic- it must happen in it's entirely of not at all,
it is difficult to ensure atomicity in a conventional file - processing
system.
(5) to solve problem of 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 2 customers withdraw funds (say $ 50 and
$ 100 respectively from account A at about the same time, the result of concurrent
executions may leave the account in at incorrect (or inconsistent) state.
Suppose the the program executing on behalf of each withdrawal read the  old balance,
reduce that value by the amount being withdrawal, and write the result back. If the 2
program run concurrently, they may both read the value $ 500, and write back $ 450 and
$ 400 respectively. Depending upon on which one writes the value 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.
(6) To solve security problem- Not every user of 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 systems in an ad- hoc manner,
enforcing such security constraints is difficult.
(7) To solve integrity problems- The data values stored in database must
satisfy certain consistency constraints. For example, the balance of a bank
account may never fall below a prescribed amount (say $ 25). Developers
enforces these constraints in the system by adding if appropriate code in the
various applications programs, however when new constraints added, it is
difficult to change the program to enforce them. The problem is compound
when constraints have involved several data items from different files. 
disadvantages of traditional file
system
File based System:-
File based systems were an early attempt to computerize the manual
filing system that we all are familiar with.

A collection of application programs that perform services for the end-


users such as the production of reports. Each program defines and
manages its own data.
The various disadvantages of keeping organizational information in a file
processing system are:
1. Data redundancy and inconsistency

The same information may be duplicated in several files.


For eg:, the address and telephone no: of a particular customer may appear
in a file that consists of savings-account records and in a file that consists of
checking-account records. This redundancy leads to higher storage and
access cost.

In addition, it may lead to data inconsistency, i.e., the various copies of the
same data may no longer agree.
For eg; a changed address may be reflected in savings-account records but
not elsewhere in the system.
2. Difficulty in accessing data
In file processing, to allow users to manipulate the information, the
system has a number of application programs. When we want a
particular set of information with file system, the system programmer
has to write the necessary application program.
Eg: customers name in a particular city.
i.e., File processing environments do not allow needed data to be
retrieved in a convenient and efficient manner.
3. Separation and isolation of data
Since data are scattered in various files, and files may be in different formats,
writing new application programs to retrieve the appropriate data is difficult.
  Data Isolation deals with consistency and completeness of data retrieved by
queries unaffecting a user data by other user actions.
4. Integrity problems
The data values stored in the database must satisfy certain types of
consistency constraints.
For eg:, the balance of a bank account may never fall below a prescribed amount.
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 program to enforce them. The problem is
compounded when constraints involve several data items from different files.
5. Atomicity problems
A computer is subject to failure. In many applications , it is
crucial that, once a failure occurs and has been detected, the data
are restored to the consistent state that existed prior to the
failure. For e.g., consider transferring of money from account A to
B. If a system failure occurs during the execution of a program, it
is possible that the money was removed from account A but was
not credited to account B, resulting in an inconsistent database
state. So the fund transfer must be atomic that means it must
happen in its entirety or not at all.
6. 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 Rs.5000/-. If two customers
withdraw funds (say Rs.500 & Rs.1000 respectively) from account A at
about the same time, the result of the concurrent executions may leave
the account in an incorrect state. If the two programs run concurrently,
they may both red the value Rs.5000, and write back Rs.4500 and Rs.4000
respectively. Depending on which one writes the vale last, the account may
contain Rs.4500 or Rs.4000, rather than the correct value of Rs.3500. To
guard against this possibility, system must maintain some form of
supervision
7.Security problems.
Not every user of the database system should be able to access all the
data. For example, in a university, payroll personnel need to see only
that part of the database that has financial information. They do not
need access to information about academic records. But, since
application programs are added to the file-processing system in an ad
hoc manner, enforcing such security constraints is difficult.
Benefits of Database Approach
oThe data can be shared.
oRedundancy can be reduced.
oInconsistency can be avoided.
oTransaction support can be provided.
oImproved security.
oImproved data integrity.
oImproved maintenance through data independence.
oIncreased concurrency.
oImproved backup and recovery services.
Basic concepts and
terminologies of database
management system
Criteria – the conditions that control which records to display in a
query.
Database – a collection of information related to a particular topic
or purpose.
There are two types of databases: Nonrelational and relational.
Database management system – a program such as Access,
that stores, retrieves, arranges, and formats information contained
in a database.
Database model – the structure of the information stored in the
database.
This model should included how each individual piece of information
relates to all the other information in the database.
Proper planning, even in the initial pencil-and-paper stage, ensures
that the database you create and maintain is efficient and provides
easy access to the information you need most.
A well-designed database should eliminate the need to enter the
same data repeatedly and prevent duplication of information, thereby
maintaining the integrity of the data.
Database modeling – the process of strategically planning where to
store each piece of information you wish to include in your database.
Field – a specific item of information containing a homogenous set of values
throughout the table. Fields appear as columns in a table and as cells in a
form.

Field data types - a characteristic of a field that determines what kind of data it
can store.
For example, a field whose data type is Text can store data consisting of either text
or number characters, but a Number field can store only numerical
data.

Field list – a small window that lists the fields of a selected table or data source.

Form – a structured document with specific areas for viewing or entering data one
record at a time. Forms can be constructed in columnar, tabular, datasheet, or a
simple justified format.
Primary Key – a field in a table whose value is uniquely identifies
each record in the table.
Query – a request for a particular collection of data in a database
Record – an individual listing of related information consisting of
a number of related fields stored in a table. A record is also called
a row in the datasheet.
Recordset – the set of records and fields that result from running
a query.
Related table – a table with a common field that uses values
stored in a primary table.
Relational database – is useful for maintaining and analyzing
complex information stored in a number of tables.
Relationship – the direct or indirect association between any two
tables in a database.
Select Query – a query that answers a question about one or
more tables by limiting the number of records and fields
displayed.
Table – an arrangement of related information stored in columns
and rows.
Views of Data – The Three- Level
Architecture
•The major purpose of a database system is to provide users with an
abstract view of the data. That is, the system hides certain details of
how the data are stored and maintained.
Data Abstraction
The system hides certain details of how the data are stored and
maintained.
To retrieve data efficiently, complex data structures are used to
represent data in the database. Since many database systems users are
not computer trained, developers hide the complexity from users
through several levels of abstraction to simplify user’s interactions with
the system.
Three tier architecture of data
view

External / View Level

Conceptual level

Internal Level

Physical data organization


1. Internal or Physical level :
The lowest level of abstraction describes how the data are actually
stored. At physical level, complexity of data structures is described in
detail.
The internal level covers the physical implementation of the database to
achieve optimal runtime performance and storage space utilization.
It covers the data structures and file organizations used to store data on
storage devices.
2. Conceptual or Logical
Level :
The next higher level of abstraction describes what data
are stored in the database and what relationships exist
among those data. It thus describes the entire database in
terms of a small number of relatively simple structures. The
conceptual level represents
◦ all entities, their attributes, and their relationships;
◦ the constraints on the data;
◦ semantic information about the data;
◦ security and integrity information.
3. View Level :
The highest level of abstraction describes only part of the entire
database. Many users of the database system do not need all the
information stored in the database, instead they need to access only
a part of the database.
The view level of abstraction exists to simplify their interaction with
the system. The system may provide many views for the same
database.
Views provide a level of security. Views can be set up to exclude data
that some users should not see. Views provide a mechanism to
customize the appearance of the database.
A view can present a consistent, unchanging picture of the structure
of the database, even if the underlying database is changed.
Characteristics of database approach
1.Self-Describing Nature of a Database System :
• One of the most fundamental characteristics of the database approach is that
the database system contains not only the database itself but also an entire
definition or description of the database structure and constraints also known
as metadata of the database. 
• This definition is stored within the DBMS  catalog, which contains information
like the structure of every file, the sort and storage format of every data item,
and various constraints/rules on the information. 
•The knowledge stored within the catalog is named meta-data, and it
describes the structure of the first database
2.Isolation between Programs and Data, and 
Data Abstraction :

•In file based system ,the structure of datafiles is defined in the


application programs.
•So if a user wants to change the structure of the file, all the programs
that access might need to be changed as well.
•In database approach, data structure is stored in system catalog & not in
programs.
3. Support for Multiple Views of the Data :

A database sometimes has many users, each of whom may require a


special perspective or view of the database. 
A view could also be a subset of the database, or it’s going to contain
virtual data that is derived from the database files but isn’t explicitly
stored. 
Some users might not get to remember whether the information they ask
for is stored or derived. 
4.Sharing of knowledge and Multi-user Transaction Processing :

• A multi-user DBMS, as its name implies, must allow multiple users to access the
database at an equivalent time or concurrently. 
• This is often essential if data for multiple applications is to be integrated and
maintained during a single database such as the latest feature of WhatsApp
integration with Facebook. 
• The DBMS must implement concurrency control in the software to make sure
that several users trying to update equivalent data do so in a controlled manner
in order that the results of the updates are correct. 
• For instance, when several reservation agents attempt to assign a seat on an
airline flight, the DBMS should make sure that each seat is often accessed by
just one user agent at a single time for an assignment to a passenger. 
•These sorts of applications are generally called online transaction processing
(OLTP) applications. A fundamental role of multi-user DBMS software is to make
sure that concurrent transactions operate correctly and efficiently with no
inconsistency. 
•The concept of a transaction has become central to several database applications. A
transaction is an executing program or process that has one or more database
accesses, like reading or updating of database records or inserting new records. 
•The isolation property ensures that every transaction appears to execute in isolation
from other transactions, many transactions could also be executed concurrently
without affecting each other. 
•The atomicity property ensures that either all the database operations during a
transaction are executed or none are, these all ACID properties we know.
Database Administrator
One of the main reasons for using DBMSs is to have central
control of both the data and the programs that access those
data. A person who has such central control over the system
is called a database administrator ( DBA).
The functions of a DBA include:
• 1.Schema definition.
The DBA creates the original database schema by executing
a set of data definition statements in the DDL(Data
Definition Language).
•2.Storage structure and access-method definition.
•3.Schema and physical-organization modification.
The DBA carries out changes to the schema and physical organization to
reflect the changing needs of the organization, or to alter the physical
organization to improve performance.
•4.Granting of authorization for data access.
By granting different types of authorization, the database administrator
can regulate which parts of the database various users can access.
The authorization information is kept in a special system structure that
the database system consults whenever someone attempts to access
the data in the system.
•5.Routine maintenance.
Examples of the database administrator’s routine maintenance activities
are:
◦Periodically backing up the database, either onto tapes or onto remote
servers, to prevent loss of data in case of disasters such as flooding.
◦Ensuring that enough free disk space is available for normal
operations,and upgrading disk space as required.
◦Monitoring jobs running on the database and ensuring that
performance is not degraded by very expensive tasks submitted by
some users.
Database Users
There are four different types of database-system users, differentiated
by the way they expect to interact with the system. Different types of
user interfaces have been designed for the different types of users.
1. Naïve Users
2. Application Programmers
3. Sophisticated Users
4. Specialized Users
1.Naive users are unsophisticated users who interact with the system
by invoking one of the application programs that have been written
previously.
For example, a clerk in the university who needs to add a new instructor
to the database
•2.Application programmers are computer professionals who write
application programs. Application programmers can choose from many
tools to develop user interfaces. Rapid application development (RAD)
tools are tools that enable an application programmer to construct forms
and reports with minimal programming effort.

•3.Sophisticated users interact with the system without writing


programs. Instead, they form their requests either using a database query
language or by using tools such as data analysis software. Analysts who
submit queries to explore data in the database fall in this category.
•E.g.: Engineers, Scientist, Business Analyst who are familiar with database.
4.Specialized users are sophisticated users who write specialized
database applications that do not fit into the traditional data-processing
framework.
Among these applications are computer-aided design systems,
knowledgebase and expert systems, systems that store data with
complex data types (for example, graphics data and audio data), and
environment-modeling systems.
Transaction management
• Transactions group a set of tasks into a single execution unit. Each
transaction begins with a specific task and ends when all the tasks in
the group successfully complete. If any of the tasks fail, the
transaction fails. Therefore, a transaction has only two results:
success or failure.

• Incomplete steps result in the failure of the transaction. A database


transaction, by definition, must be atomic, consistent, isolated
and durable. These are popularly known as ACID properties.
Transaction Manager
• A transaction is a collection of operations that performs a single
logical function in a database application.
• Each transaction is a unit of both atomicity and consistency. Thus, we
require that transactions do not violate any database-consistency
constraints. That is, if the database was consistent when a transaction
started, the database must be consistent when the transaction
successfully terminates.
• Transaction - manager ensures that the database remains in a
consistent (correct) state despite system failures (e.g., power failures
and operating system crashes) and transaction failures.
Structure of DBMS
Structure of a DBMS
 A database system is partitioned into modules that deal with
each of the responsibilities of the overall system.

 The functional components of a database system can be broadly


divided into the storage manager and the query processor
components.

 The storage manager is important because databases typically


require a large amount of storage space.
Structure of a DBMS
 The query processor is important because it helps the database
system to simplify and facilitate access to data.
 It is the job of the database system to translate updates and queries
written in a nonprocedural language, at the logical level, into an
efficient sequence of operations at the physical level.
Structure of a DBMS
Query Processor
• The query processor components include
• DDL interpreter, which interprets DDL statements and
records the definitions in the data dictionary.
• DML compiler, which translates DML statements in a query
language into an evaluation plan consisting of low-level instructions
that the query evaluation engine understands.
Structure of a DBMS
• A query can usually be translated into any of a number of alternative
evaluation plans that all give the same result. The DML compiler also
performs query optimization, that is, it picks the lowest cost
evaluation plan from among the alternatives.
• Query evaluation engine, which executes low- level
instructions generated by the DML compiler.
Structure of a DBMS
Storage Manager
• A storage manager is a program module that provides the 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 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.
Structure of a DBMS
 The storage manager components include:
1. Authorization and integrity manager
2. Transaction manager
3. File manager
4. Buffer manager

1) Authorization and integrity manager, which tests for the satisfaction of


integrity constraints and checks the authority of users to access data.
2) Transaction manager, which ensures that the database remains in a
consistent (correct) state despite system failures, and that concurrent
transaction executions proceed without conflicting.
Structure of a DBMS
3) File manager, which manages the allocation of space on disk storage
and the data structures used to represent information stored on
disk.
4) 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.
Storage manager implements several data structures:
1. Data Files: Which store database itself.
2. Data Dictionary: Which stores metadata about structure of database
, the schema of the data.
3. Indices : Which provide fast access data items that hold particular
values.
Instances and Schemas:-
The collection of information stored in the database at a particular
moment is called an instance of the database.
A schema describes the organization of data and relationships within the
database. i.e., the overall design of the database is called the database
schema.
A database schema corresponds to the variable declarations in a
program. Each variable has a particular value at a given instant. The
values of the variables in a program at a point in time correspond to an
instance of a database schema.
According to the levels of abstraction, database systems
have several schemas.
◦ The physical schema (internal schema) describes the
database design at the physical level,
◦ The logical schema (conceptual schema) describes the
database design at the logical level.
◦ The schemas at the view level can be called as sub
schemas (external schema) and they describe views of
the database for particular users.
Data Independance
Data independence is the ability to modify the scheme without
affecting the programs and the application to be rewritten. Data is
separated from the programs, so that the changes made to the
data will not affect the program execution and the application.
There are two levels of data independence based on three levels
of abstraction. These are as follows −
• Physical Data Independence
• Logical Data Independence
1. Physical Data Independence
Physical Data Independence means changing the physical level without affecting
the logical level or conceptual level. The changes in the physical level may include
changes using the following −
 A new storage device like magnetic tape, hard disk, etc.
 A new data structure for storage.
 A different data access method or using an alternative files organization
technique.
 Changing the location of the database.

2. Logical Data Independence


Logical view of data is the user view of the data. It presents data in the form that
can be accessed by the end users. The changes in the logical level may include −
 Change the data definition.
 Adding, deleting, or updating any new attribute, entity or relationship in the
database.
Database languages
Database languages, also known as query languages or data query
languages, are a classification of programming languages that
developers use to define and access databases, which are collections of
organized data that users can access electronically.
These languages allow users to complete tasks such as controlling
access to data, defining and updating data and searching for
information within the database management system (DBMS).
Database Languages are:

1. Data Definition Language(DDL)


2. Data Manipulation Language(DML)
3. Data Control Language(DCL)
4. Transaction Control Language(TCL)
1. Data definition language (DDL)

Data definition language (DDL) creates the framework of the


database by specifying the database schema, which is the
structure that represents the organization of data.
Here's a list of DDL statements:
•CREATE: Creates a new database or object, such as a table,
index or column
•ALTER: Changes the structure of the database or object
•DROP: Deletes the database or existing objects
•RENAME: Renames the database or existing objects
2. Data manipulation language (DML)

Data manipulation language (DML) provides operations that


handle user requests, offering a way to access and
manipulate the data that users store within a database.
 Its common functions include inserting, updating and
retrieving data from the database. Here's a list of DML
statements:
INSERT: Adds new data to the existing database table
UPDATE: Changes or updates values in the table
DELETE: Removes records or rows from the table
SELECT: Retrieves data from the table or multiple tables
3. Data control language (DCL)
Data control language (DCL) controls access to the data that users store
within a database. Essentially, this language controls the rights and
permissions of the database system. It allows users to grant or revoke
privileges to the database. Here's a list of DCL statements:
•GRANT: Gives a user access to the database
•REVOKE: Removes a user's access to the database

4. Transaction control language (TCL)


Transaction control language (TCL) manages the transactions within a
database. Transactions group a set of related tasks into a single,
executable task. All the tasks must succeed in order for the transaction to
work. Here's a list of TCL statements:
•COMMIT: Carries out a transaction
•ROLLBACK: Restores a transaction if any tasks fail to execute
•SAVEPOINT: Sets a point in a transaction to save
Data Models
A collection of conceptual tools for describing data, data relationships,
data semantics, and consistency constraints.
A data model provides a way to describe the design of a database at
the physical, logical, and view levels.
Data modelling is the first step in the process of database design. This
step is sometimes considered to be a high-level and abstract design
phase, also referred to as conceptual design. The aim of this phase is to
describe:
1. The data contained in the database (e.g., entities: students,
lecturers, courses, subjects)
2. The relationships between data items (e.g., students are supervised
by lecturers; lecturers teach courses)
3. The constraints on data (e.g., student number has exactly
eight digits; a subject has four or six units of credit only)
1.Relational Model.

The relational model uses a collection of tables to represent both data


and the relationships among those data.
Tables are also called Relations.
 This type of model designs the data in the form of rows and columns
within a table.
This model was initially described by E.F Codd in1969.
The relational data model is widely used model which is primarily used
by commercial data processing applications.
2.Entity-Relationship Data Model
An E-R Model is the logical representation of data as Objects and
Relationships among them.
These Objects are knows as Entities and relationship is an association
among these entities.
This model was designed by Peter Chen.
It was widely used in database3 designing. A lot of attributes describe
the entities. For e.g.: Student-Name, Student-Id, describes the student
entity.
A set of same type of entities is known as an “Entity sets” and the set
of same type of relationship is known as “Relationship set”
3. Object based Data Model
An Extension of the E-R model with notions of functions, encapsulation
and object identity.
As well this model supports a rich type of system that includes
Structured and collection types. Thus in 1980’s various database system
following the object oriented approach were developed.
Here the object are nothing but the data carrying its properties.
4.Semi-structured Data Models
This type of data model is different from the other three data models.
The semi-structure data model allows the data specifications of places
where the individual data items of the same type may have different
attribute set.
The Extensible markup language also known as XML is widely used for
representing the semi structured data . It gains importance because of
its applications in the exchange of data.
E-R Model
E-R 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.
It develops a conceptual design for the database. It also develops a very
simple and easy to design view of data.
In E-R modeling, the Database structure is portrayed as a diagram called
an Entity-Relationship Diagram.
For e.g.: 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.

Name Address

Student

Id Age
Components of ER Diagram
Entity Attributes Relation

Weak Entity Key Attributes One to One

Strong Entity Composite Attributes One to Many

Multivalued Attributes Many to One

Derived Attributes Many to Many


Entity

An entity is a real-world thing which can be distinctly identified like a person,
place or a concept.
Entity Set is a collection or a group of ‘entities’ sharing exactly the ‘same set of
attributes’. 
 In E-R Diagram, Entity is represented using Rectangles.

An entity can be of two types:


1. Strong Entity
2. Weak Entity
1. Strong Entity:
Strong entity are those entity types which has a key attribute. The primary key
helps in identifying each entity uniquely. It is represented by a rectangle. In the
above example, Roll_no identifies each element of the table uniquely and hence,
we can say that STUDENT is a strong entity type.
2. Weak Entity:
Weak entity type doesn't have a key attribute. It depends upon some
other strong entity for its distinct identity. There can be a room only if
building exits. There can be no independent existence of a room. A weak
entity is represented by a double outlined rectangle.
The relationship between a weak entity type and strong entity type is
called an Identifying relationship and shown with a double outlined
diamond instead of a single outlined diamond.
Attributes
Attributes are the properties which define the entity type. For
example, Roll_No, Name, DOB, Age, Address, Mobile_No are the
attributes which defines entity type Student. In ER diagram, attribute is
represented by an oval shape. 

1. Key Attribute – 


The attribute which uniquely identifies each entity in the entity set is
called key attribute.For example, Roll_No will be unique for each
student. In ER diagram, key attribute is represented by an oval with
underlying lines.
2. Composite Attribute – 
An attribute composed of many other attribute is called as composite
attribute. For example, Address attribute of student Entity type consists
of Street, City, State, and Country. In ER diagram, composite attribute is
represented by an oval comprising of ovals. 

3. Multivalued Attribute – 
An attribute consisting more than one value for a given entity. For
example, Phone_No (can be more than one for a given student). In ER
diagram, multivalued attribute is represented by double oval. 
4. Derived Attribute – 
An attribute which can be derived from other attributes of the entity
type is known as derived attribute. e.g.; Age (can be derived from DOB).
In ER diagram, derived attribute is represented by dashed oval. 
RELATIONSHIP
An association among entities is called Relationship. A relationship is represented by
diamond shape in ER diagram, it shows the relationship among entities.
Relationships too can have attributes, these attributes are called Descriptive
Attributes.
Relationship Set-
A relationship set is a set of relationships of same type.
Example-

Degree of Relationship: The no of participating entities in a relationship is


called Degree of Relationship.
1. Unary- Degree 1
2. Binary- Degree 2
3. Ternary- Degree 3
Mapping Cardinality: The number of entities to which another entity can be
associated via a relationship set.
There are four types of relationships:
1. One to One
2. One to Many
3. Many to One
4. Many to Many
1. One to One
When a single instance of an entity is associated with a single instance of
another entity then it is called one to one relationship. For example, a person
has only one passport and a passport is given to one person.

AAAAAAAAAAAA
2.One to Many Relationship  
When a single instance of an entity is associated with more than one instances of another entity then
it is called one to many relationship. For example – a customer can place many orders but a order
cannot be placed by many customers.

ADSAFDSDFSF

3. Many to One Relationship                


When more than one instances of an entity is associated with a single instance of another entity then
it is called many to one relationship. For example – many students can study in a single college but a
student cannot study in many colleges at the same time.

ADSAFDSDFSF
4. Many to Many Relationship                 
When more than one instances of an entity is associated with more than
one instances of another entity then it is called many to many relationship.
For example, a can be assigned to many projects and a project can be
assigned to many students.

AADHBHJHJJBJJBHJBHJBHJB
HJFSFGFXFG
E-R Diagram
Geometric shapes and meaning in ER diagram

adfdfsfdgfdgdgfghfhgfhj
DBMS Keys
•Keys play an important role in the relational database.
•It is used to uniquely identify any record or row of data from the table. It is
also used to establish and identify relationships between tables.
For example: In Student table, ID is used as a key because it is unique for
each student. In PERSON table, passport_number, license_number, SSN are
keys since they are unique for each person.
Types of key:

You might also like