0% found this document useful (0 votes)
12 views

DBMS

The document discusses the components and types of users in a database management system (DBMS). It defines data and describes how a DBMS manages data. It also lists different types of users that play roles in a DBMS, including application programmers and database administrators.

Uploaded by

Amit purohit
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

DBMS

The document discusses the components and types of users in a database management system (DBMS). It defines data and describes how a DBMS manages data. It also lists different types of users that play roles in a DBMS, including application programmers and database administrators.

Uploaded by

Amit purohit
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 56

ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY

BHOPAL

DBMS MCA-201
Unit-1
By
Prof. Amit Rajpurohit
Basic of DBMS ⮚ Why we need Information:

⮚ Data : ❑ In gain Knowledge about the surrounding


❑To keep the system up to date
❑ The collection of Raw facts ❑To know about the rules and regulation of
❑ The fact that can be recorded and have implicit meaning know as society
data
❑Example: Sname, Age, Empname etc.. ⮚Knowledge :

⮚ Information: Human mind purposefully organize the


information and evaluate it to produce Knowledge
❑ Processing of raw Data
❑ Fact Based:
❑It is the data that has been converted into more useful or
intelligible form. The Knowledge gain from fundamental
❑Example: Report card and through experiment
❑ Heuristic Based
The real goal is to turn data into information.
It is Knowledge of good practice and good
judgment like hypothesis
Database :

Definition:

A database is a collection of interrelated data. By data, we mean known facts that can be recorded and
that have implicit meaning.
• Data can be store in form of table.
• Database can be of any size & varying complexity .
• A database may be generated & manipulated manually or computerized.

Example:
Ename Salary Age
Database Management System Application of DBMS
Definition: • Banking
• Finance
A database management system is a collection of programs that enables • HR Management
users to create and maintain a database. The database management system • Manufacturing
or dbms is a general-purpose software system that facilitates the processes • Universities
of defining, constructing, manipulating, and sharing databases among • Airlines
various users and applications. • Railway System

DBMS Software
• MySQL
User DBMS • Microsoft Access
Database • Oracle
• PostgreSQL
• FoxPro
• SQLite
• IBM DB2
Operation Perform on Database: Types of file systems
• Insertion ❑ File allocation table (FAT)
• Updation is supported by the Microsoft Windows OS. FAT is
• Deletion considered simple and reliable, and it is modeled after legacy file
• Retrieve systems. FAT was designed in 1977 for floppy disks, but was
• Sorting later adapted for hard disks.
• Min ❑ Global file system (GFS):
• Max is a file system for the Linux OS, and it is a shared disk file
etc... system. GFS offers direct access to shared block storage and can
be used as a local file system.
File System
❑ Hierarchical file system (HFS)
• Before DBMS invented, information was stored in file was developed for use with Mac operating systems. HFS can
processing system. also be referred to as Mac OS Standard, and it was succeeded by
• A file processing system is a collection of files and programs Mac OS Extended. Originally introduced in 1985 for floppy and
that access/modify these files hard disks, HFS replaced the original Macintosh file system.
• Typically, new files and programs are added over time (by ❑ New Technology File System (NTFS):
different programmers) as new information needs to be stored is the default file system for Windows products from Windows
and new ways to access information are needed. Problems with NT 3.1 OS onward. Improvements from the previous FAT file
file processing systems: system include better metadata support, performance and use of
disk space.
Limitation/ Disadvantage of file ⮚ Domain Constrains ⮚Referential Integrity Constrains
processing system Eid Name Age Phone
ID Name Sem Age
101 ravi 5 17 101 ravi 35 982610123
❑ Data Redundancy 4
❑ Difficulty in accessing data 102 raj 5 abc 102 raj 38 999336667
❑ Data isolation 5
❑ Atomicity problem 103 ajay 25 799995678
❑ Concurrent access anomalies 9
❑Integrity Constrains ⮚Entity Integrity Constrains
❑Security Problems Primary Key Value should not be null Table -1

Integrity Constrains:
Phone Location
It is a set of rules and it is used for maintain quality
9826101234 Bhopal
information.
9993366675 Mumbai
7999956789 Pune
⮚Key Constrains
Table -2
primary key must be unique
and two same PK value not Table No. 1 for Phone No. is Foreign key
allow in record Table No. 2 . For Phone No is Primary key
Advantage of DBMS over File System
❑ Redundancy can be reduced by normalization
❑ Inconsistency can be avoided
❑ Data can be shared
❑ Security restrictions can be applied
❑ Integrity constrains are also available and can be applied
❑ Requirements can be balanced
❑ Atomicity is also in DBMS transaction
❑ Locking mechanism also there to prevent concurrent access
❑ Standards can be enforced
User:
Components of DBMS
Types of user who play different roles in DBMS
Data:
 A data can be defined as a collection of  Application Programmers
raw facts and figures.
The users who write the application programs in
 The term database is referred as a
programming languages (such as
collection of the related data.
Java, Python ,C++,etc )to interact with
 The data is a key component and for the
databases are called Application Programmer.
management of it the DBMS works.
Software:
 Database Administrators (DBA)
Software is the actual DBMS b/w the
physical DB and the user of the system all Person who manages the overall DBMS is
request from the user for accessing the DB called a database administrator or
are handled by DBMS software simply DBA

Hardware:  End-Users
Procedures:
The hardware is the actual computer system
The end-users are those who interact with
used for keeping and accessing the database
the database management system to perform Procedures are instructions and rules that assist
conventional DBMS Hardware consist of
different operations by using the different on how to use the DBMS, in its design and
secondary storage devices
database commands such running the database. They serve as a guide to
as insert, update, retrieve, and delete on the the users that operate and manage it.
data, etc.
DBMS - Architecture

1-tier Architecture 2-tier Architecture 3-tier Architecture


1-Tier Architecture
DBMS - Architecture
 In this architecture, the database is directly available to the user. It means the
 Design of DBMS depends on its architectures it can be
user can directly sit on the DBMS and uses it.
Centralized ,decentralized or hierarchical.
 Any changes done here will directly be done on the database itself. It doesn't
Architecture of DBMS can be Single tier or multitier
provide a handy tool for end users.
 in one tier DBMS is only entity where user directly sits
 The 1-Tier architecture is used for development of the local application, where
on the DBMS and User it any changes will directly be done
programmers can directly communicate with the database for the quick response.
on DBMS it self.
 User (Presentation) Tier
2-Tier Architecture 3-tier Architecture
End-users operate on this tier and
 The 2-Tier architecture is same as basic client-server. A 3-tier architecture separates its tiers from
they know nothing about any
In the two-tier architecture, applications on the client end each other based on the complexity of the users
existence of the database beyond
can directly communicate with the database at the server and how they use the data present in the
this layer. At this layer, multiple
side. For this interaction, API'slike: ODBC, JDBC are database. It is the most widely used architecture
views of the database can be
used. to design a DBMS.
provided by the application. All
 The user interfaces and application programs are run  Database (Data) Tier views are generated by applications
on the client-side. that reside in the application tier.
database resides along with its query
The server side is responsible to provide the
processing languages. We also have the
functionalities like: query processing and transaction
relations that define the data and their
management.
constraints at this level.
 To communicate with the DBMS, client-side
application establishes a connection with the server side.  Application (Middle) Tier
It contains application server& program to
access database .it provides abstract view of
database to users. Hence it works as mediator
b/w end users
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Data Model:
Types of data models
 Data Model gives us an idea that how the final system
will look like after its complete implementation.
 It defines the data elements and the relationships The types of data models are of the following
between the data elements. types. These are also called database models.
 Data Models are used to show how data is stored,
connected, accessed and updated in the database
 Hierarchical Database Model
management system.
 we use a set of symbols and text to represent the  Relational Database Model
information so that members of the organization can
 Network Database Model
communicate and understand it.
Advantage of a data model  Object-Oriented Database Model
 Increased effectiveness data integrity
 E-R Model
Reduced costs faster performance
 simplicity Reduced errors

Minimum redundancy Reduced risk


ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Hierarchical Database model
There is a parent-child relationship. In this
model, each entity has only one parent and
many abstract children. There is only one entity
in this model that we call root.
In this model, data is organized in a tree-like
structure, which has only one root. In this, the
data is stored as records that are connected to
each other. It was proposed in 1970.
Advantages of Hierarchical Disadvantages of
Features of a Hierarchical Model Hierarchical Model
Model
 It is very simple and fast to traverse
 One-to-many relationship  Complex relationships are
through a tree-like structure.
 Parent-Child Relationship  Any change in the parent node is not supported.
 Deletion Problem  If a parent node is deleted
automatically reflected in the child node
so, the integrity of data is maintained. then the child node is
automatically deleted.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Relational Database Model

 In this model, data is stored in relations i.e. tables and


each relation has rows and columns.
A relational model is a group of tables in which data and
relationships are specified.
 In this, the data is stored in two-dimensional tables, the
tables are also called a relation. And the row of each table
is called a tuple. The tuple represents the entity and the
column of the table represents the attribute.
The relational model was proposed by E.F Codd in 1969 Disadvantages of Relational
and since then this model has been used the most . Model
Advnatages of Relational
Features of Relational Model  It requires powerful hardware computers,
Model storage devices, and software.
 Tuples: : Each row in the table is  Simple: t is very easy to use but when a user stores
called tuple. A row contains all the data in it incorrectly then it becomes very bad
 Scalable
information about any instance of the DBMS.
object. Structural Independence This is a very simple model, due to its
 Attribute or field: Attributes are the simplicity, some users create their own
property which defines the table or database, causing the problem of data
inconsistency, data duplication.
relation. The values of the attribute
should be from the same domain.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
NETWORK DATABASE
MODEL
This model is an extension of the hierarchical
model.
 In a network model, data is organized into
graphs. And it can have more than one parent
node.
I n a network model, data is organized into
graphs.
FeaturesAndof
it can have more
a Network than one parent
Model
node.
 Features of a Network Model
 Many paths
A disadvantage of the network model
Advantage of a network
model • Its database structure is very complex (difficult)
Its concept is as simple as the hierarchical
model. because all the records in it are maintained using
• There is more than one parent/child pointers.
relationship. • Changes in its structure require changes in all
• Data can be accessed easily in it. programs.
• It provides data integrity.
• It contains a data definition language (DDL) and
data manipulation language (DML).
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
OBJECT-ORIENTED DATABASE MODEL

In an object-oriented model, information or data is displayed as


an object and these objects store the value in the instance
variable.

The real-world problems are more closely represented through the


object-oriented data model. In this model, both the data and
relationship are present in a single structure known as an object. We
can store audio, video, images, etc in the database which was not
possible in the relational model

Advantage of the object-oriented model Disadvantage of the object-oriented model

• Semantic content can be put in it. • It requires a powerful system due to which the transaction is very
• It supports inheritance which increases data slow.
integrity. • It is a very complex model.
• It improves performance. • To use it, one has to learn it first.
• There is very little security in it.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
DBMS Schema
Definition: Design of a database is called the
schema.

 Schema is the overall description of the database.


The basic structure of how the data will be stored in
the database is called schema.
 it is the description of database.
 Not expect to change frequently
 A display schema is called a schema diagram.
A database schema is the skeleton structure of the Schema is of two types: Logical Schema, and
database. It represents the logical view of the entire Physical Schema.
database. Logical Schema – It describes the database designed at logical
A schema contains schema objects like table, level.
foreign key, primary key, views, columns, data types, Physical Schema – It describes the database designed at
stored procedure, etc. physical level.
 A database schema is designed by the database
designers to help programmers whose software will
interact with the database. The process of database
creation is called data modeling.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Data Independence
Data independence refers characteristic of being
able to modify the schema at one level of the
database system without altering the schema at
the next higher level.

There are two types of data


independence:
 Logical Data Independence

 Logical data independence refers characteristic of


being able to change the conceptual schema without  Physical Data Independence
having to change the external schema.  Physical data independence can be defined as the capacity to change
 Logical data independence is used to separate the the internal schema without having to change the conceptual schema.
external level from the conceptual view.  If we do any changes in the storage size of the database system
 If we do any changes in the conceptual view of the server, then the Conceptual structure of the database will not be affected.
data, then the user view of the data would not be  Physical data independence is used to separate conceptual levels from
affected. the internal levels.
Logical data independence occurs at the user interface  Physical data independence occurs at the logical interface level.
level.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
DBMS Instance Different State of
The data stored in database at a particular moment of time is called
Database
instance of database. Empty State : When we define a new
 Database schema defines the variable declarations in tables
database
that belong to a particular database; the value of these
variables at a moment of time is called the instance of that Initial State: When database is first populated
database. Current State: a state of database at any point
 At a particular moment the data stored in database is called of time
the instance, that changes over time when we add or delete Schema Evolution: When we need to change
data from the database.
Example
the schema
we have a single table student in the database, today the
table has 100 records, so today the instance of the
database has 100 records. Lets say we are going to add
another 100 records in this table by tomorrow so the
instance of database tomorrow will have 200 records in
table
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Database Languages & Interface:
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
DQL (Data Query Language) :
Database Languages & Interface:
DQL Command is to get some schema relation based on
DDL ( Data definition Language ) the query passed to it.

 For Describing data & data structure Example of DQL:


 Deals with table structure SELECT – is used to retrieve data from the database.
Examples of DDL commands:
 CREATE – is used to create the database or its objects (like DML (Data Manipulation language)
table, index, function, views, store procedure and triggers).
 Deals with records
 DROP– is used to delete objects from the database.  Like Store, Search,, delete,insert,Update,etc
 ALTER -is used to alter the structure of the database.
Examples of DML:
 TRUNCATE –is used to remove all records from a table, including  INSERT – is used to insert data into a table.
all spaces allocated for the records are removed.  UPDATE– is used to update existing data within a table.
COMMENT –is used to add comments to the data dictionary.  DELETE – is used to delete records from a database
 RENAME –is used to rename an object existing in the database.
table.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]

DCL (Data Control language)


TCL(transaction Control Language):
 There are control statements which are
executed on pre defined conditions TCL commands deal with the transaction within the database.

It includes –Triggers, Assertion


Examples of TCL commands:
Examples of DCL commands:

 COMMIT– commits a Transaction.


 GRANT -gives users access privileges to  ROLLBACK– rollbacks a transaction in case of any error occurs.
the database.  SAVEPOINT–sets a savepoint within a transaction.
 REVOKE -withdraw user’s access  SET TRANSACTION–specify characteristics for the transaction.
privileges given by using the GRANT
command.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]

Functions and Responsibilities of DBAs

DBA: person in the organization who controls the design and the
5. Approving Data Access:
use of the database refers as DBA.
The DBA determines which user needs access to which
1. Schema Definition: part of the database.
The DBA definition the logical Schema of the database. A Schema According to this, various types of authorizations are
refers to the overall logical structure of the database. granted to different users.
According to this schema, database will be developed to store 6. Monitoring Performance:
required data for an organization. The DBA monitors performance of the system. The DBA
2. Storage Structure and Access Method Definition: ensures that better performance is maintained by making
The DBA decides how the data is to be represented in the stored changes in physical or logical schema if required.
database. 7. Backup and Recovery:
3. Assisting Application Programmers: Database should not be lost or damaged.
The DBA provides assistance to application programmers to develop The DBA ensures this periodically backing up the
application programs. database on magnetic tapes or remote servers.
4. Physical Organization Modification: In case of failure, such as virus attack database is
The DBA modifies the physical organization of the database to recovered from this backup.
reflext the changing needs of the organization or to improve
performance.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]

Codd's Rule :
Every database has tables, and
constraints cannot be referred to as a
rational database system. And if any
database has only relational data model,
it cannot be a Relational Database
System (RDBMS) . So, some rules define
a database to be the correct RDBMS.

These rules were developed by Dr. Edgar


F. Codd (E.F. Codd) in 1985,
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Rule 6 View Updating Rule:
Codd rules were proposed by E.F. Codd which should be satisfied Different views created for various purposes should be
by relational model. automatically updatable by the system.
Rule 0 Foundation Rule: Rule 7 High level insert, update and delete rule:
For any system that is advertised as, or claimed to be, a Relational Model should support insert, delete, update
relational data base management system, that system must be able etc. operations at each level of relations. Also, set operations like
to manage data bases entirely through its relational capabilities. Union, Intersection and minus should be supported.
Rule 1 Information Rule: Rule 8 Physical data independence:
Data stored in Relational model must be a value of some Any modification in the physical location of a table
cell of a table. should not enforce modification at application level.
Rule 2 Guaranteed Access Rule: Rule 9 Logical data independence:
Every data element must be accessible by table name, Any modification in logical or conceptual schema of a
its primary key and name of attribute whose value is to be table should not enforce modification at application level. For
determined. example, merging of two tables into one should not affect
Rule 3 Systematic Treatment of NULL values: application accessing it which is difficult to achieve.
NULL value in database must only correspond to Rule 10 Integrity Independence:
missing, unknown or not applicable values. Integrity constraints modified at database level should
Rule 4 Active Online Catalog: not enforce modification at application level.
Structure of database must be stored in an online Rule 11 Distribution Independence:
catalog which can be queried by authorized users. Distribution of data over various locations should not
Rule 5 Comprehensive Data Sub-language Rule: be visible to end-users.
A database should be accessible by a language Rule 12 Non-Subversion Rule: Low level access to data should
supported for definition, manipulation and transaction management not be able to bypass integrity rule to change data.
operation.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Entity-Relationship Model
Entity-Relationship Model or simply ER Model is a high-level
data model diagram.
In this model, we represent the real-world problem in the
pictorial form to make it easy for the stakeholders to
understand.
It is also very easy for the developers to understand the
system by just looking at the ER diagram. We use the ER
diagram as a visual tool to represent an ER Model.
Components
Entities: Entity is a real-world thing. It can be a person, place, or
even a concept. Example: Teachers, Students, Course, Features of ER Model
Building, Department, etc
Attributes: An entity contains a real-world property called Graphical Representation for Better Understanding
attribute. This is the characteristics of that ER Diagram
attribute. Example: The entity teacher has the property like
Database Design
teacher id, salary, age, etc.
Relationship: Relationship tells how two attributes are
related. Example: Teacher works for a department.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Advantages of ER Model Disadvantages of ER Model
Simple:

Conceptually ER Model is very easy to build. If we know the No industry standard for notation:
relationship between the attributes and the entities we can easily build There is no industry standard for developing an ER
the ER Diagram for the model.
model. So one developer might use notations which
Effective Communication Tool: are not understood by other developers.
This model is used widely by the database designers for
communicating their ideas. Hidden information: Some information might be lost
or hidden in the ER model. As it is a high-level view
Easy Conversion to any Model: so there are chances that some details of information
This model maps well to the relational model and can be easily might be hidden.
converted relational model by converting the ER model to the table.
This model can also be converted to any other model like network
model, hierarchical model etc.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Component of ER Diagram
Entity Set
1. Entity:
An Entity is an object of Entity Type
An entity may be any object, class, person or and set of all entities is called as
place. In the ER diagram, an entity can be entity set.
represented as rectangles.

 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.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
2. Attribute Types of Attribute Composite Attribute
The attribute is used to describe the
Key Attribute An attribute composed of many other
property of an entity. Eclipse is used to
represent an attribute. The attribute which uniquely identifies attribute is called as composite attribute.
each entity in the entity set is called key For example, Address attribute of student
attribute. Entity type consists of Street, City, State,
For example, Roll_No will be unique for and Country. In ER diagram, composite
each student. In ER diagram, key attribute is represented by an oval
attribute is represented by an oval with comprising of ovals.
underlying lines.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
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.

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.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
One-to-One Relationship
Relationship When only one instance of an entity is associated with the relationship,
A relationship is used to describe the relation then it is known as one to one relationship.
between entities. Diamond or rhombus is used example, A female can marry to one male, and a male can marry
to represent the relationship. to one female.

One-to-many relationship
Types of 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
 One-to-One Relationship a one-to-many relationship.
 One-to-many Relationship
example, Scientist can invent many inventions, but the invention
 Many-to-one Relationship
is done by the only specific scientist.
 Many-to-many Relationship
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Many-to-one relationship
Many-to-many relationship

When more than one instance of the entity on the left, and
When more than one instance of the entity on the left, and
only one instance of an entity on the right associates with
more than one instance of an entity on the right associates
the relationship then it is known as a many-to-one
with the relationship then it is known as a many-to-many
relationship.
relationship.
Example, Employee can assign by many projects and project
example, Student enrolls for only one course, but a can have many employees.
course can have many students.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Participation:
How many entities are going to be participated in
relationship
Total Participation
 if all the entities of an entity set participation in
relationship set then the participate is called total
participation
Total Participation − Each entity is involved in
the relationship. Total participation is represented
by double lines.
(One to many relation Total)

Partial Participation:

 If some entities participated then it is partial


participation
 Partial participation − Not all entities are
involved in the relationship. Partial participation
is represented by single lines.
Total Participation of an Entity set
• Total participation of an entity set represents that each entity in entity set must have at least one relationship in a
relationship set. It is also called mandatory participation. For example: In the following diagram each college
must have at-least one associated Student. Total participation is represented using a double line between the
entity set and relationship set.
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]

Recursive Relationship

 When an entity set play more than one role


in a relationship set then it is called Recursive
Relationship

 In E-R Diagram we don’t have to write any


thing with links but in Recursive Relationship
we have to specify the role of an entity in that
relationship that's why we would have to
specify name/role on the links.

 Beside that we have to write nothing such


type of E-R diagram are called “E-R diagram
with role Indicator”
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Some Extended Features of E-R Diagram (EER)

 Aggregation
Specialization & Generalization

Aggregation

 Relationship among the relationship


It is used to represent a relationship between
a whole object and its component part.
It allow us to indicate that a relationship set
participate in another relationship set
It is an abstraction for building composite
objects from their component object.
 It is represented by ---- Dashed line in E-R
diagram
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Specialization & Generalization

Specialization
One entity is specialized into some
other entities by adding some special
attributes.
It is Top-Down Approach.
Shows conversion of higher level
entities into lower level entity by
adding some additional attributes.
Lower level will inherit by higher
level attributes.
Generalization

Reverse of Specialization
Bottom up approach
Combining similar attributes to one
general class
G/S

Generalization is a bottom-up approach in which


multiple lower-level entities are combined to form a
single higher-level entity. Generalization is usually
used to find common attributes among entities to form
a generalized entity. It can also be thought of as the
opposite of specialization.

Specialization is a top-down approach in which a


higher-level entity is divided into
multiple specialized lower-level entities.

03/28/24
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
Online RR System

03/28/24
HM System

03/28/24
Table to ER

03/28/24
Table
Column/Attribute

Row/Record

Domain

03/28/24
SQL DATATYPE
Create Table

UNIQUE,

INSERT QUERY

03/28/24
SQL PROGRAMMING
• Data Definition Language (DDL)
• Data Definition Language (DDL) is a set of special commands that allows us to define and modify the structure and the
metadata of the database. These commands can be used to create, modify, and delete the database structures such
as schema, tables, indexes, etc.
• Since DDL commands can alter the structure of the whole database and every change implemented by a DDL command is
auto-committed (the change is saved permanently in the database), these commands are normally not used by an end-user
(someone who is accessing the database via an application).

• CREATE DATABASE database_name;


• To create a new table :
• CREATE TABLE table name ( column_1 DATATYPE, column_2 DATATYPE, column_n DATATYPE );

03/28/24
SQL PROGRAMMING

• DROP
• It is used to delete the database or its schema objects.
• DROP TABLE table name;
• To delete the whole database :
• DROP DATABASE database name;
• ALTER :
• It is used to modify the structure of the database objects.
Syntax -
• To add new column(s) in a table :
• ALTER TABLE table name ADD ( column_1 DATATYPE, column_2 DATATYPE, column DATATYPE );
• To change the data type of a column in a table :
• ALTER TABLE table name MODIFY column name DATATYPE;

03/28/24
SQL PROGRAMMING

remove a column from a table :


• ALTER TABLE table name DROP COLUMN column name;
• TRUNCATE :
• It is used to remove the whole content of the table along with the deallocation of the
space occupied by the data, without affecting the table's structure.
• MySQL Syntax -
• To remove data present inside a table :
• TRUNCATE TABLE table name;
• RENAME:

03/28/24
SQL PROGRAMING
• Data Manipulation Language (DML)
• Data Manipulation Language (DML) is a set of special commands that allows us to
access and manipulate data stored in existing schema objects. These commands are
used to perform certain operations such as insertion, deletion, updation, and retrieval
of the data from the database.
• These commands deal with the user requests as they are responsible for all types of
data modification. The DML commands that deal with the retrieval of the data are
known as Data Query language.
SELECT :
• It is used to retrieve or fetch data from a database. The SELECT statement cannot
manipulate data, it can only access it. Hence, it is known as the Data Query Language,
i.e., a limited form of DML statement.

• MySQL Syntax -
•To fetch an entire table :
SELECT * FROM table name;
•To fetch particular columns from a table :
SELECT column_1, column_2 FROM table_name;
•To fetch particular columns from a table based on a condition:
SELECT column_1, column_2 FROM table_name WHERE <condition>;

03/28/24
SQL PROGRAMMING
• INSERT :
It is used to insert new rows into the table.
• MySQL Syntax -
• To insert values according to the table structure :
• INSERT INTO table_name VALUES value1, value2, value3;
• To insert values based on the columns :
• INSERT INTO table_name column1, column2, column3 VALUES value1, value2, value3;
• UPDATE :
• It is used to update existing column(s)/value(s) within a table.
• MySQL Syntax -
• To update the columns of a table based on a condition (General UPDATE statement) :
• UPDATE table name SET column_1 = value1, column_2 = value2, column_3 = value3,
[WHERE condition]

03/28/24
MY SQL PROGRAMMING
• 1) Show databases; ///showing the databases
• 2) Create database demo;
• 3) Use demo; // database changed
• use demo; //table use
• select * from (previous database);
• 4) Create table student (name varchar (30), id int not null primary key, address varchar
(50), marks int);
• 5) Desc student; /// describe table name
• 6) insert into student(name,id,address,marks)values(‘ranber’,101,Mumbai,50); //secure
way
• 7) Insert into student values (‘ranbera’, 102, Mumbayi, 52)//unsecure way
• 8) Insert into student values (‘ranber1’, 201, Mumbaina, 100), (‘aliya’, 301, bhaitunda,
200)); //multivalue insert
• Query ok, 2 rows affected

03/28/24
MY SQL PROGRAMMING

• 9) Select * from student; //All table


• 10) Select name, address from student; //specific column
• 11) Select * from student where id=200;// specific record or row
• 12) update student set address=’Delhi’ where name=’ranbeer’);
• 13) Alter table student ADD phone no int; //ADD the new column
• Now select * from student; the new column value is “NULL”.
• 14) Alter table student ADD phone no int; //ADD the new column

03/28/24
MY SQL PROGRAMMING
• 15) Alter table student modify column name varchar(30); //ADD the new size/dty
• 16) Alter table student drop column phone no;//remove column name
• Desc student; //to show again the remaining column
• 17) delete from student where name =”ranbeer”;
• 18)rollback; //last value rollback whether insert or delete// use start transaction;
• 19)commit;
• Function
• Select sum (marks) from student;
• Select average (marks) from student;
• Select count (name) from student;
• Select max (marks) from student;
• Select min (marks) from student;
• Select * from student order by name; //ascending order
• Select *from student order by name desc; //descending order

03/28/24
MY SQL PROGRAMMING

• //wild card//
• Select * from student where name like’r%’; start with r
• Select * from student where name like’%r’; end with r
• Select * from student where name like’’_r%’; //second character
• Select * from student where name like’’%r_’; //last second character

03/28/24
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY BHOPAL
[www.oriental.ac.in]
ORIENTAL INSTITUTE OF SCIENCE AND TECHNOLOGY
BHOPAL

Thank You

You might also like