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

DBMS1

Uploaded by

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

DBMS1

Uploaded by

Shubhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 42

What is DBMS

• DBMS stands for Database Management System.


• We can break it like this DBMS = Database + Management System.
• Database is a collection of data and Management System is a set of
programs to store and retrieve those data.
• Based on this we can define DBMS like this: DBMS is a collection of
inter-related data and set of programs to store & access those data in
an easy and effective manner.
What is the need of DBMS?
• Database systems are basically developed for large amount of data.
When dealing with huge amount of data, there are two things that
require optimization: Storage of data and retrieval of data.
• Storage: According to the principles of database systems, the data is
stored in such a way that it acquires lot less space as the redundant
data (duplicate data) has been removed before storage. Ex: Banking.
• Fast Retrieval of data: Along with storing the data in an optimized
and systematic manner, it is also important that we retrieve the data
quickly when needed. Database systems ensure that the data is
retrieved as quickly as possible.
Database Applications

• Telecom
• Industry
• Banking System
• Sales
• Airlines
• Education sector
• Online shopping
File Oriented approach:
• The traditional file oriented approach to information processing has
for each application a separate master file and its own set of personal
file.
• In file oriented approach the program dependent on the files and files
become dependent on the files and files become dependents upon
the programs.
Disadvantages of file oriented approach:
• Data redundancy
• Data inconsistency
• Difficulty in accessing data: conventional file processing system
• Data Isolation: data are scattered in various file
• Dependency on application programs
• Atomicity issues: Atomicity of a transaction refers to “All or nothing”
• Concurrent access
• Data Security
Advantage of DBMS over file system
• No redundant data
• Data Consistency and Integrity
• Data Security
• Privacy: Limited access
• Easy access to data
• Easy recovery
DBMS Level Architecture
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.
Conceptual level
• It is also called logical level. The whole design of the database such as
relationship among data, schema of data etc. are described in this level.
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.
Types of DBMS languages
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 Comment – Comment
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
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
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
ER Diagram

• An Entity–relationship model (ER model) describes the structure of a


database with the help of a 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.
Components of a ER Diagram
Entity
• An entity is an object or component of data. An entity is represented
as rectangle in an ER diagram.
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
Key attribute

• A key attribute can uniquely identify an entity from an entity set. For
example, student roll number can uniquely identify a student from a
set of students.
Composite attribute

• An attribute that is a combination of other attributes is known as


composite attribute.
Multivalued attribute
• An attribute that can hold multiple values is known as multivalued
attribute. It is represented with double ovals in an ER Diagram.
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.
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
One to One Relationship
One to Many Relationship
Many to One Relationship
Many to Many Relationship
Total Participation of an Entity set
• A Total participation of an entity set represents that each entity in
entity set must have at least one relationship in a relationship set.
ER example
• In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses. Each course is taught by a
single Professor. To maintain instruction quality, a Professor can
deliver only one course.

• Step 1) Entity Identification


ER example
• In a university, a Student enrolls in Courses. A student must be
assigned to at least one or more Courses. Each course is taught by a
single Professor. To maintain instruction quality, a Professor can
deliver only one course.

• Step 1) Entity Identification

• Student
• Course
• Professor
• Step 2) Relationship Identification
• Step 2) Relationship Identification

• The student is assigned a course


• Professor delivers a course
• Step 3) Cardinality Identification
• Step 3) Cardinality Identification

• A student can be assigned multiple courses


• A Professor can deliver only one course
• Step 4) Identify Attributes

• Entity Primary Key Attribute


• Student Student_ID StudentName
• Professor Employee_ID ProfessorName
• Course Course_ID CourseName
• Suppose you are given the following requirements for a simple
database for the National Hockey League (NHL):
• the NHL has many teams,
• each team has a name, a city, a coach, a captain, and a set of players,
• each player belongs to only one team,
• each player has a name, a position (such as left wing or goalie), a skill
level, and a set of injury records,
• a team captain is also a player.
Candidate Key using Functional Dependencies
• A -> B
• B -> C
• C -> A
• Let's suppose we have a set of attributes as S: {A, B, C, D,
E, F} and functional dependencies are:
• AB -> C
• B -> AE
• C -> D
• Let's suppose we have a set of attributes as S: {A, B, C, D,
E} and functional dependencies are:
• CE -> D
• D -> B
• C -> A
• Given R (E-ID, E-NAME, E-CITY, E-STATE)
• FDs = { E-ID->E-NAME, E-ID->E-CITY, E-ID->E-STATE, E-CITY->E-STATE }
• Let's suppose we have a set of attributes as S: {W, X, Y, Z}
and functional dependencies are:
• Z -> W
• Y -> XZ
• XW -> Y
• Let's suppose we have a set of attributes as S: {A, B, C, D,
E, F} and functional dependencies are:
• AB -> C
• C-> D
• D -> BE
• E -> F
• F -> A
• Let's suppose we have a set of attributes as S: {A, B, C, D,
E, F, G, H} and functional dependencies are:
• A -> BC
• E -> A
• B -> CFH
• CH -> G
• F -> EG

You might also like