The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

Unit Wise notes for BCA and MCA students

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Pradeep Bhandari, 2020-08-28 04:43:41

DBMS Notes

Unit Wise notes for BCA and MCA students

DATABASE MANAGEMENT SYSTEM

UNIT-1

As the name suggests, the database management system consists of two parts. They are:
Database and Management System.
Data: Facts, figures, statistics etc. having no particular meaning (e.g. 1, ABC, 19 etc).
OR
Data is a collection of facts, figures and statistics related to an object. For example:
Students fill an admission form when they get admission in college. The form consists of
raw facts about the students. These raw facts are student's name, father name, address
etc. The purpose of collecting this data is to maintain the records of the students during
their study period in the college.

What is a Database?

To find out what database is, we have to start from data, which is the basic building
block of any DBMS.
Database: Collection of related relations.
OR Roll_No Name Age

Database is collection of related data. 101 PQR 20

Table or Relation: Collection of related records. 102 XYZ 21
The columns of this relation are called Fields,
Attributes or Domains. The rows are called 103 BCD 22

Tuples or Records.

What is Management System?

A management system is a set of rules and procedures which help us to create organize and

manipulate the database. It also helps us to add, modify delete data items in the database.
The management system can be either manual or computerized.

INFORMATION: Processed data is called information. OR The manipulated and processed
form of data is called information. For example: Data collected from census is used to
generate different type of information. The government can use it to determine the literacy
rate in the country. Government can use the information in important decision to improve
literacy rate.

What is DBMS ?
DBMS is a software or set of programs which helps us in the creation, definition and
manipulation of database. DBMS allow users to store, process and access the data easily.
we have lot of advantages of DBMS.
User interact with dbms by an interface generally this interface is a command user
interface.
SQL Structured Query Language commands are used on most of the database.
DBMS gives the facility to the user to protect the databases used in database management
system.
It also provide a way so that multiple user can use the same database. Some widely used
dbms in industry are MySql,Oracle,SQL Server ,IBM DB2.

Application DBMS OS DATABASE

Characteristics of DBMS:-

Data stored into Tables: Data is never directly stored into the database. Data is
stored into tables, created inside the database.
Reduced Redundancy: DBMS follows Normalisation which divides the data in such
a way that repetition is minimum.
Data Consistency: On Live data, i.e. data that is being continuously updated and
added, maintaining the consistency of data can become a challenge. But DBMS
handles it all by itself.
Support Multiple user and Concurrent Access: DBMS allows multiple users to work
on it(update, insert, delete data) at the same time and still manages to maintain
the data consistency.
Query Language: DBMS provides users with a simple Query language, using which
data can be easily fetched, inserted, deleted and updated in a database.
Security: The DBMS also takes care of the security of data, protecting the data
from un-authorised access. In a typical DBMS, we can create user accounts with
different access permissions, using which we can easily secure our data by
restricting user access.
Transaction Support: DBMS supports transactions, which allows us to better
handle and manage data integrity in real world applications where multi-threading
is extensively used.

ADVANTAGES OF THE DBMS:
1. Improved data sharing
2. Improved data security
3. Data integration
4. Minimized data inconsistency
5. Improved data access
6. Improved decision making
7. Increased end-user productivity
8. Controlling Data Redundancy
9. Backup and Recovery Procedures

DISADVANTAGES OF DBMS:
1. Increased costs: As DBMS needs computers, we have to invest a good amount in

acquiring the hardware, software, installation facilities and training of users.
2. We have to keep regular backups because a failure can occur any time. Taking

backup is a lengthy process and the computer system cannot perform any other job
at this time.
3. While data security system is a boon for using DBMS, it must be very robust. If
someone can bypass the security system then the database would become open to
any kind of mishandling.

SCHEMA:

A schema is a collection of named objects.
Schemas are generally stored in a data dictionary.
A graphical depiction of the database structure.
Some of the objects that a schema may contain include tables, views, aliases, indexes,
triggers, and structured types.

INSTANCES:

The data in the database at a particular moment of time is called an instance or a
database state.
Every time we update (i.e., insert, delete or modify) the value of a data item in a record,
one state of the database changes into another state.

Schema STUDENT

Instances ROLL_NO NAME COURSE AGE
101 AMAR BCA 17
102 KIRTI MCA 21
103 RAVI BCA 18

Data Dictionary:-

A data dictionary is a centralized repository of metadata.
Metadata is data about data.
Some examples of what might be contained in an organization’s data dictionary :

The names of fields contained in all of the organization’s databases.
What table(s) each field exists in
What database(s) each field exists in
The data types, e.g., integer, real, character, and image of all fields in the organization’s
databases
The sizes, e.g., LONG INT, DOUBLE, and CHAR(64), of all fields in the organization’s
databases
An explanation of what each database field means
The source of the data for each database field
The relationship between fields in all of the organization’s databases
Default values that exist for all fields in all of the organization’s databases
Who has access to each field

What is Meta Data?

Metadata is data about the data or documentation about the information which is
required by the users.
Metadata includes the following:
1. The location and descriptions of warehouse systems and components.
2. Names, definitions, structures, and content of data-warehouse and end-users views.
3. Identification of authoritative data sources.
4. Integration and transformation rules used to populate data.
5. Integration and transformation rules used to deliver information to end-user

analytical tools.
6. Subscription information for information delivery to analysis subscribers.
7. Metrics used to analyze warehouses usage and performance.
8. Security authorizations, access control list, etc.

DATABASE ADMINISTRATOR

The people responsible for managing databases are called database
administrators.
The responsibilities of a DBA:
1.Designing the logical and physical schemas, as well as widely-used portions of
the external schema.
2.Security and authorization.
3.Data availability and recovery from failures.
4.Database tuning: The DBA is responsible for evolving the database, in particular
the conceptual and physical schemas to ensure adequate performance as user
requirements change.

USERS IN DBMS Users are of 4 types:
1. Application programmers or Ordinary users
2. End users
3. Database Administrator (DBA)
4. System Analyst
1. Application programmers or Ordinary users: These users write application programs to

interact with the database. Application programs can be written in some
programming language such a COBOL, PL/I, C++, JAVA or some higher level fourth
generation language. Such programs access the database by issuing the appropriate
request, typically a SQL statement to DBMS.
2. End Users: End users are the users, who use the applications developed. End users
need not know about the working, database design, the access mechanism etc. They
just use the system to get their task done. End users are of two types: a) Direct users
b) Indirect users
a) Direct users: Direct users are the users who se the computer, database system
directly, by following instructions provided in the user interface. They interact using
the application programs already developed, for getting the desired result. E.g. People
at railway reservation counters, who directly interact with database.
b) Indirect users: Indirect users are those users, who desire benefit form the work of
DBMS indirectly. They use the outputs generated by the programs, for decision
making or any other purpose. They are just concerned with the output and are not
bothered about the programming part.

3.Database Administrator (DBA):
Database Administrator (DBA) is the person which makes the strategic and policy
decisions regarding the data of the enterprise, and who provide the necessary technical
support for implementing these decisions. Therefore, DBA is responsible for overall
control of the system at a technical level. In database environment, the primary resource
is the database itself and the secondary resource is the DBMS and related software
administering these resources is the responsibility of the Database Administrator (DBA).

4. System Analyst:
System Analyst determines the requirement of end users, especially naive and parametric
end users and develops specifications for transactions that meet these requirements.
System Analyst plays a major role in database design, its properties; the structure
prepares the system requirement statement, which involves the feasibility aspect,
economic aspect, technical aspect etc. of the system.

DATA MODEL:

The entire structure of a database can be described using a data model.
A data model is a collection of conceptual tools for describing Data models can be
classified into following types.
1.Object Based Logical Models.
2.Record Based Logical Models.
3.Physical Models.

1.Object Based Logical Models: These models can be used in describing the data at the
logical and view levels.
These models are having flexible structuring capabilities classified into following types.
a)The entity-relationship model.
b)The object-oriented model.
c)The semantic data model.
d)The functional data model
2.Record Based Logical Models: These models can also be used in describing the data at
the logical and view levels. These models can be used for both to specify the overall
logical structure of the database and a higher-level description. These models can be
classified into,
1.Relational model.2.Network model.3.Hierarchal model

3. Physical Models: These models can be used in describing the data at the lowest
level, i.e. physical level. These models can be classified into1.Unifying model2.Frame
memory model.

Relational model(one to one): This type of model designs the data in the form of rows
and columns within a table. Thus, a relational model uses tables for representing data
and in-between relationships. Tables are also called relations. This model was initially
described by Edgar F. Codd, in 1969. The relational data model is the widely used
model which is primarily used by commercial data processing applications.

VENDOR

EMPLOYEE CUSTOMER PRODUCT

SALES
TRANSACTION

Network model(many to many): The network model builds on the hierarchical model
by allowing many-to-many relationships between linked records, implying multiple
parent records. Based on mathematical set theory, the model is constructed with sets
of related records. Each set consists of one owner or parent record and one or more
member or child records. A record can be a member or child in multiple sets, allowing
this model to convey complex relationships.

Hierarchal model (one to many): The hierarchical model organizes data into a tree-like
structure, where each record has a single parent or root. Sibling records are sorted in a
particular order. That order is used as the physical order for storing the database. This
model is good for describing many real
-world.

4.Object-Oriented Model:
Object DBMSs add database functionality to object programming languages. They bring
much more than persistent storage of programming language objects. A major benefit of
this approach is the unification of the application and database development into a
seamless data model and language environment. As a result, applications require less
code, use more natural data modelling, and code bases are easier to maintain.
5. Semi structured Data Model:
This type of data model is different from the other three data models (explained above).
The semi structured data model allows the data specifications at places where the
individual data items of the same type may have different attributes sets. The Extensible
Mark-up Language, also known as XML, is widely used for representing the semi
structured data. Although XML was initially designed for including the mark-up
information to the text document, it gains importance because of its application in the
exchange of data.
5. Entity Relationship (ER) Model:
The entity-relationship (E-R) model is the most popular conceptual model used for
designing a database. It was originally proposed by Dr. Peter Chen in 1976 as a way to
unify the network and relational database views. The E-R model views the real world as a
set of basic objects (known as entities), their characteristics (known as attributes), and
associations among these objects (known as relationships). The entities, attributes, and
relationships are the basic constructs of an E-R model.

FILE SYSTEM VS. DATA BASE MANAGEMENT SYSTEM.

1. Files act locally where as DBMS saves directly in a database
2. Saves in temporary locations where as DBMS in well arranged and permanent data

base locations.
3. in File System Transactions are not possible where as various transactions like insert,

delete, view, updating etc are possible in DBMS.
4. Data will be accessed through single or various files where as in DBMS, tables

(schema) is used to access data
5. A "File manager" is used to store all relationships in directories in File Systems where

as a data base manager (administrator) stores the relationship in form of structural
tables
6. Last.... but not the least.... Data in data bases are more secure compared to data in
files!!
Disadvantages in File Processing:
Data redundancy and inconsistency.
Difficult in accessing data.
Data isolation. Data integrity.
Concurrent access is not possible.
Security Problems.

People who deal with databases

Many persons are involved in the design, use and maintenance of any database. These
persons can be classified into 2 types as below.
[A] Actors on the scene:
The people, whose jobs involve the day-to-day use of a database are called as 'Actors
on the scene', listed as below .
1.Database Administrators (DBA)
2.Database Designers
3. End Users
4.System Analyst
5.Application Programmers (Software Engineers)
1.Database Administrators (DBA): Already discussed.
2.Database Designers:
Database designers are responsible for identifying the data to be stored in the
database and for choosing appropriate structures to represent and store this data.
3. End Users:
People who wish to store and use data in a database.
End users are the people whose jobs require access to the database for querying,
updating and generating reports, listed as below.
a. Casual End users:
These people occasionally access the database, but they may need different
information each time.

b. Naive or Parametric End Users:
Their job function revolves around constantly querying and updating the database using
standard types of queries and updates.
c. Sophisticated End Users:
These include Engineers, Scientists, Business analyst and others familiarize to
implement their applications to meet their complex requirements.
d. Stand alone End users:
These people maintain personal databases by using ready-made program packages that
provide easy to use menu based interfaces.
4.System Analyst:
These people determine the requirements of end users and develop specifications for
transactions.
5.Application Programmers (Software Engineers):
These people can test, debug, document and maintain the specified transactions .

[B] Workers behind the scene:
1.Database Designers and Implementers:
These people who design and implement the DBMS modules and interfaces as a
software package.
2.Tool Developers:
Include persons who design and implement tools consisting the packages for design,
performance monitoring, and prototyping and test data generation.

3.Operators and maintenance personnel:
These re the system administration personnel who are responsible for the actual running
and maintenance of the hardware and software environment for the database system.

LEVELS OF DATA ABSTRACTION
OR

Database system concepts and Architecture

A Database Management system is not always directly available for users and applications
to access and store data in it.
A Database Management system can be centralised(all the data stored at one location),
decentralised(multiple copies of database at different locations)
or
hierarchical, depending upon its architecture.

1-tier DBMS architecture also exist, this is when the database is directly available to the
user for using it to store data. Generally such a setup is used for local application
development, where programmers communicate directly with the database for quick
response.
Database Architecture is logically of two types:
2-tier DBMS architecture
3-tier DBMS architecture

2-tier DBMS Architecture

2-tier DBMS architecture includes an Application layer between the user and the

DBMS, which is responsible to communicate the user's request to the database

management system and then send the response from the DBMS to the user.

An application interface known as ODBC(Open Database Connectivity) provides an API

that allow client side program to call the DBMS. Most DBMS vendors provide ODBC

drivers for their DBMS. DBMS

Application Layer

User/Client

Such an architecture provides the DBMS extra security as it is not exposed to the End
User directly. Also, security can be improved by adding security and authentication
checks in the Application layer too.

3-tier DBMS Architecture

3-tier DBMS architecture is the most commonly used architecture for web applications.
DBMS

Application Layer

GUI/Presentation
Layer

User/Cleint

It is an extension of the 2-tier architecture. In the 2-tier architecture, we have an application layer
which can be accessed programatically to perform various operations on the DBMS. The application
generally understands the Database Access Language and processes end users requests to the DBMS.
In 3-tier architecture, an additional Presentation or GUI Layer is added, which provides a graphical user
interface for the End user to interact with the DBMS.
For the end user, the GUI layer is the Database System, and the end user has no idea about the
application layer and the DBMS system.
If you have used MySQL, then you must have seen PHPMyAdmin, it is the best example of a 3-tier
DBMS architecture.

DBMS – Three Level Architecture (or 3-tier)
In the previous tutorial we have seen the DBMS architecture– one-tier, two-tier and
three-tier. In this guide, we will discuss the three level DBMS architecture in detail.

DBMS Three Level Architecture Diagram
This architecture has three levels:

This architecture has three levels:
1. External level
2. Conceptual level
3. Internal level

1. External level
It is also called view level. The reason this level is called “view” is because several
users can view their desired data from this level which is internally fetched from
database with the help of conceptual and internal level mapping.
The user doesn’t need to know the database schema details such as data structure,
table definition etc. user is only concerned about data which is what returned back
to the view level after it has been fetched from database (present at the internal
level).
External level is the “top level” of the Three Level DBMS Architecture.

2. Conceptual level
It is also called logical level or global level. The whole design of the database such
as relationship among data, schema of data etc. are described in this level.
Database constraints and security are also implemented in this level of architecture.
This level is maintained by DBA (database administrator).The most commonly used
conceptual model is the E-R model.
3. Internal level
This level is also known as physical level. This level describes how the data is
actually stored in the storage devices. This level is also responsible for allocating
space to the data. This is the lowest level of the architecture

Data Independence

An important objective of the three-tier architecture is to provide data independence,
which means that the upper levels are unaffected by changes in the lower levels.
Defn :“The ability to modify a schema definition in one level without affecting a schema
definition in the next higher level is called DI.”
Types of Data Independence
1.Physical data independence
2.Logical data independence.

1.Physical data independence
Physical data independence helps you to separate conceptual levels from the
internal/physical levels. It allows you to provide a logical description of the database
without the need to specify physical structures.
Due to Physical independence, any of the below change will not affect the conceptual
layer.
Using a new storage device like Hard Drive or Magnetic Tapes
Modifying the file organization technique in the Database
Switching to different data structures.
Changing the access method.
Modifying indexes.
Changes to compression techniques or hashing algorithms.
Change of Location of Database from say C drive to D Drive

2.Logical data independence
Logical Data Independence is the ability to change the conceptual scheme without
changing
External views
External API or programs

Due to Logical independence, any of the below change will not affect the external layer.
Add/Modify/Delete a new attribute, entity or relationship is possible without a rewrite
of existing application programs
Merging two records into one
Breaking an existing record into two or more records

DI is much similar to the concept of ADT in C++,JAVA etc.(both hides implementation
details from the users.)

DBMS languages
Database languages are used to read, update and store data in a database. There are several
such languages that can be used for this purpose; one of them is SQL (Structured Query
Language).
Types of DBMS languages:
1.DDL (Data definition language)
2.DML (Data Manipulation language)
3.DCL (Data Control language)
4.TCL (Transaction control language)

1. Data Definition Language (DDL)
DDL is used for specifying the database schema. It is used for creating tables, schema,
indexes, constraints etc. in database. Lets see the operations that we can perform on
database using DDL:
To create the database instance – CREATE
To alter the structure of database – ALTER
To drop database instances – DROP
To delete tables in a database instance – TRUNCATE
To rename database instances – RENAME
To drop objects from database such as tables – DROP
To Comment – Comment

2.Data Manipulation Language (DML)
DML is used for accessing and manipulating data in a database. The following operations
on database comes under DML:
To read records from table(s) – SELECT
To insert record(s) into the table(s) – INSERT
Update the data in table(s) – UPDATE
Delete all the records from the table – DELETE

3.Data Control language (DCL)
DCL is used for granting and revoking user access on a database –
To grant access to user – GRANT
To revoke access from user – REVOKE

DDL,DM,DCL are not separate language, rather they are the parts of a single database
language such as SQL.

3.Transaction Control Language(TCL)
The changes in the database that we made using DML commands are either performed or
rollbacked using TCL.
To persist the changes made by DML commands in database – COMMIT
To rollback the changes made to the database – ROLLBACK

Interfaces in DBMS

A database management system (DBMS) interface is a user interface which
allows for the ability to input queries to a database without using the query
language itself.
User-friendly interfaces provide by DBMS may include the following:
1.Menu-Based Interfaces for Web Clients or Browsing:
These interfaces present the user with lists of options (called menus) that lead
the user through the formation of a request. Basic advantage of using menus is
that they removes the tension of remembering specific commands and syntax
of any query language, rather than query is basically composed step by step by
collecting or picking options from a menu that is basically shown by the system.
Pull-down menus are a very popular technique in Web based interfaces. They
are also often used in browsing interface which allow a user to look through
the contents of a database in an exploratory and unstructured manner.
2.Forms-Based Interfaces : A forms-based interface displays a form to each
user. Users can fill out all of the form entries to insert a new data, or they can
fill out only certain entries, in which case the DBMS will redeem same type of
data for other remaining entries.

This type of forms are usually designed or created and programmed for the users that
have no expertise in operating system.
Many DBMSs have forms specification languages which are special languages that help
specify such forms.
Example: SQL* Forms is a form-based language that specifies queries using a form
designed in conjunction with the relational database schema.
3.Graphical User Interface –
A GUI typically displays a schema to the user in diagrammatic form. The user then can
specify a query by manipulating the diagram. In many cases, GUI’s utilize both menus
and forms. Most GUIs use a pointing device such as mouse, to pick certain part of the
displayed schema diagram.
4.Natural language Interfaces –
These interfaces accept request written in English or some other language and attempt
to understand them. A Natural language interface has its own schema, which is similar
to the database conceptual schema as well as a dictionary of important words. The
natural language interface refers to the words in its schema as well as to the set of
standard words in a dictionary to interpret the request. If the interpretation is
successful, the interface generates a high-level query corresponding to the natural
language and submits it to the DBMS for processing, otherwise a dialogue is started
with the user to clarify any provided condition or request. The main disadvantage with
this is that the capabilities of this type of interfaces are not that much advance.

5.Speech Input and Output –
There is an limited use of speech say it for a query or an answer to a question or being a
result of a request it is becoming commonplace Applications with limited vocabularies
such as inquiries for telephone directory, flight arrival/departure, and bank account
information are allowed speech for input and output to enable ordinary folks to access this
information.
The Speech input is detected using a predefined words and used to set up the parameters
that are supplied to the queries. For output, a similar conversion from text or numbers
into speech take place.
6.Interfaces for DBA –
Most database system contains privileged commands that can be used only by the DBA’s
staff. These include commands for creating accounts, setting system parameters, granting
account authorization, changing a schema, reorganizing the storage structures of a
databases.

Database Objective type questions

In the relational modes, cardinality is termed as:
(A) Number of tuples. (B) Number of attributes.
(C) Number of tables. (D) Number of constraints.
The view of total database content is
(A) Conceptual view. (B) Internal view.
(C) External view. (D) Physical View.
Architecture of the database can be viewed as
(A) two levels. (B) four levels.
(C) three levels. (D) one level.
In a relational model, relations are termed as
(A) Tuples. (B) Attributes
(C) Tables. (D) Rows.
The database schema is written in
(A) HLL (B) DML
(C) DDL (D) DCL
In the architecture of a database system external level is the
(A) physical level. (B) logical level.
(C) conceptual level (D) view level.
In a Hierarchical model records are organized as
(A) Graph. (B) List.
(C) Links. (D) Tree.
A relational database developer refers to a record as
(A) a criteria. (B) a relation.
(C) a tuple. (D) an attribute.

An advantage of the database management approach is
(A) data is dependent on programs.
(B) data redundancy increases.
(C) data is integrated and can be accessed by multiple programs.
(D) none of the above.
Which of the following are the properties of entities?
(A) Groups (B) Table
(C) Attributes (D) Switchboards
The conceptual model is
(A) dependent on hardware.
(B) dependent on software.
(C) dependent on both hardware and software .
(D) independent of both hardware and software

UNIT-2

History of DBMS:-

1950s and early 1960s :-

Data processing using magnetic tapes for storage
• Tapes provide only sequential access
• Punched cards for input

Late 1960s and 1970s:
• Hard disks allow direct access to data
• Network and hierarchical data models in widespread use

1980s:
• Research relational prototypes evolve into commercial systems
• SQL becomes industrial standard
• Parallel and distributed database systems
• Object-oriented database systems

1990s:
• Large decision support and data-mining applications
• Large multi-terabyte data warehouses
• Emergence of Web commerce

2000s:
• XML and XQuery standards
• Automated database administration

Entity Relationship Model (E-R Model) :

An ER model describes the structure of a database with the help of a diagram, which is
known as ER Diagram.
An ER model is a design or blueprint of a database that can later be implemented as a
database.
The main components of E-R model are: entity set and relationship set.
These models can be used for the conceptual design of database applications.

To understand about the ER Model, we must know about:
Entity and Entity Set
Attributes, Types of Attributes
Keys
Relationships

ER Diagram: An ER diagram shows the relationship among entity sets.

OR
ER-Diagram is a pictorial representation of data that describes how data is communicated
and related to each other.

Notation of E-R Diagram

Rectangle: Represents Entity sets.
Ellipses: Attributes
Diamonds: Relationship Set
Lines: They link attributes to Entity Sets and Entity sets to Relationship Set
Double Ellipses: Multivalued Attributes
Dashed Ellipses: Derived Attributes
Double Rectangles: Weak Entity Sets
Double Lines: Total participation of an entity in a relationship set

An ER diagram has three main components:
1. Entity
2. Attribute
3. Relationship
1. Entity: They are represented using the rectangle-shaped box.
An entity is an object or component of data.

Employee Student Project

Entity type: It is a group of objects with the same properties that are identified by the
enterprise as having an independent existence.
Each entity type is shown as a
rectangle labelled with the name of
the entity, which is usually a
singular noun.

Weak Entity:
An entity that cannot be uniquely identified by its own attributes and relies on the
relationship with other entity is called weak entity. The weak entity is represented by a
double rectangle.

Attribute
An attribute describes the property of an entity. An attribute is represented as Oval in an
ER diagram. There are four types of attributes:
1. Key attribute
2. Composite attribute
3. Multivalued attribute
4. Derived attribute
1. Key attribute:
A key attribute can uniquely identify an entity from an entity set.
For example, student roll number.
Key attribute is represented by oval same as other attributes however the text of key
attribute is underlined.

2. Composite attribute:
An attribute that is a combination of other
attributes is known as composite attribute.

3. Multivalued attribute:
An attribute that can hold multiple values is known as multivalued attribute. It is
represented with double ovals in an ER Diagram.
For example – A person can have more than one phone numbers so the phone number
attribute is multivalued.
4. Derived attribute:
A derived attribute is one whose value is dynamic and derived from another attribute.
It is represented by dashed oval in an ER Diagram.
For example – Person age is a derived attribute as it changes over time and can be
derived from another attribute
(Date of birth).

3. Relationship
A relationship is represented by diamond shape in ER diagram, it shows the relationship
among entities. 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 only a single instance of an entity is associated with the
relationship, it is termed as '1:1'.

2. One-to-many: When more than one instance of an entity is related and linked with a
relationship, it is termed as '1:N'.

3. Many-to-one: When more than one instance of an entity is linked with the
relationship, it is termed as 'N:1'.

4. Many-to-many: When more than one instance of an entity on the left and more than
one instance of an entity on the right can be linked with the relationship, then it is
termed as N:N relationship.

Weak Entity
Weak entity is an entity that depends on another entity. Weak entity doesn't have any
key attribute of its own. Double rectangle is used to represent a weak entity.

Loan Installment

Degree of Relationship:

The number of an entity type that is connected to a relationship is the degree of that
relationship.
Based on the number of entity types that are connected we have the following degree of
relationships:
1. Unary
2. Binary
3. Ternary
4. N-ary



Structural Constraints of Relationships in ER Model:

To understand Structural Constraints, we must take a look at Cardinality Ratios and
Participation Constraints.

Cardinality Ratios :-

There are numbers (M and N) written above the lines which connect relationships and
entities. These are called cardinality ratios.

Types of Cardinality :

One-to-one (1:1) –
When one entity in each entity set takes part at most once in the relationship, the cardinality
is one-to-one.
One-to-many (1: N) –
If entities in the first entity set take part in the relationship set at most once and entities in
the second entity set take part many times (at least twice), the cardinality is said to be one-
to-many.

Many-to-one (N:1) –
If entities in the first entity set take part in the relationship set many times (at least
twice), while entities in the second entity set take part at most once, the cardinality is
said to be many-to-one.
Many-to-many (N: N) –
If entities in both the entity sets take part many times (at least twice) in the relationship
set.

Participation Constraints :
Participation Constraints tell us that the participation in a relationship can either be total
or partial.
When each entity in an entity set participates in a relation, it is called Total Participation.
However,
when all entities in the given entity set do not participate in a relation, it is called Partial
Participation.

Structural Constraints :

Structural Constraints are also called Structural properties of a database management
system (DBMS).
Cardinality Ratios and Participation Constraints taken together are called Structural
Constraints.

KEY constraints:

Key

A key is an attribute or set of attributes which helps us in uniquely identifying the rows of a table.
A Key can be a single attribute or a group of attributes, where the combination may act as a key.

Candidate Key:

Candidate keys are defined as the minimal set of fields which can uniquely identify each record in a
table. It is an attribute or a set of attributes that can act as a Primary Key for a table to uniquely
identify each record in that table. There can be more than one candidate key.

STUDENT Name Phone Age
Roll_No

1 Ajay 1212121212 17
2 Amar 3232323232 19
3 Bharat 5656565656 18
4 Charu 7878787878 19
5 Disha 9898989898 17

Roll_No and phone both are candidate keys for table Student.

A candidate key can never be NULL or empty.
Its value should be unique.
There can be more than one candidate keys for a table.
A candidate key can be a combination of more than one columns(attributes).

Primary Key:

Primary key is a candidate key that is most appropriate to become the main key for any
table.
It is a key that can uniquely identify each record in a table.
For the table Student we can make the Roll_No column as the primary key.
It is selected from a set of candidate keys.
Any candidate key can become a primary key.
It depends upon the requirements and is done by the Database Administrator (DBA).
The primary key cannot have a NULL value.
It cannot have a duplicate value.

Alternate Key:

All the candidate key which are not a primary key are called an alternate key.

Super Key:

A super key is a combination of all possible attribute which can uniquely identify the
rows(tuples) in a table.
This means that a super key may have some extra attribute which isn't necessary for
uniquely identifying the rows in the table.

{Roll_no}
{Registration_no}
{Roll_no, Registration_no},
{Roll_no, Name}
{Name, Registration_no}
{Roll_no, Name, Registration_no}

All the above keys are able to uniquely identify each row.
So, each of these keys is super key.
Super key vs Candidate Key
A candidate key is a minimal super key with no redundant attributes.

Foreign Key:

The foreign key of a table is the attribute which establishes the relationship among
tables.
The foreign key is the attribute which points to the primary key of another table.

Composite Key

Key that consists of two or more attributes that uniquely identify any record in a table is
called Composite key.
But the attributes which together form the Composite key are not a key independently or
individually.

Enhanced Entity Relationship Model (EER Model)

EER is a high-level data model that incorporates the extensions to the original ER model.
It is a diagrammatic technique for displaying the following concepts
Sub Class and Super Class
Specialization and Generalization
Union or Category
Aggregation

Features of EER Model

EER creates a design more accurate to database schemas.
It reflects the data properties and constraints more precisely.
It includes all modeling concepts of the ER model.
Diagrammatic technique helps for displaying the EER schema.
It includes the concept of specialization and generalization.
It is used to represent a collection of objects that is union of objects of different of
different entity types.
Sub Class and Super Class: Sub class and Super class relationship leads the concept of
Inheritance.
The relationship between sub class and super class is denoted with symbol


Click to View FlipBook Version