DBMS Unit-1
DBMS Unit-1
Class - T.Y.PLD
(Division-)
AY 2024-2025
SEM-I
1
MIT School of Computing
Department of Computer Science & Engineering
2
MIT School of Computing
Department of Computer Science & Engineering
Syllabus
PLD
3
MIT School of Computing
Department of Computer Science & Engineering
PLD
4
MIT School of Computing
Department of Computer Science & Engineering
PLD
5
Unit – I
6
MIT School of Computing
Department of Computer Science & Engineering
Syllabus
Introduction :
Database
• Collection of related data that is stored in a central location
or in multiple locations
8
Interaction Between the User, DBMS and Database
Disadvantage of File-oriented system
Data Redundancy:
• It is possible that the same information may be duplicated in different files. this
leads to data redundancy results in memory wastage.
Data Inconsistency:
• Because of data redundancy, it is possible that data may not be in
consistent state.
Difficulty in Accessing Data:
• Accessing data is not convenient and efficient in file processing system.
Limited Data Sharing:
• Data are scattered in various files. Also different files may have
different formats and these files may be stored in different
folders may be of different departments.
• So, due to this data isolation, it is difficult to share data among
different applications.
Integrity Problems:
• Data integrity means that the data contained in the database in
both correct and consistent. for this purpose the data stored in
database must satisfy correct and constraints.
Atomicity Problems:
• Any operation on database must be atomic.
• this means, it must happen in its entirely or not at all.
Concurrent Access Anomalies:
• Multiple users are allowed to access data simultaneously. this is
for the sake of better performance and faster response.
Security Problems:
• Database should be accessible to users in limited way.
• Each user should be allowed to access data concerning his
Levels of Abstraction
If there are two entity type ‘Customer’ and ‘Account’ then each ‘Customer’ can
have more than one ‘Account’ but each ‘Account’ is held by only one
‘Customer’. In this example, we can say that each Customer is associated with
many Account. So, it is a one-to-many relationship. But, if we see it the other
way i.e many Account is associated with one Customer then we can say that it
is a many-to-one relationship.
Many-to-Many Relationship
• Double line between the entity set “Student” and relationship set “Enrolled
in” signifies total participation.
• It specifies that each student must be enrolled in at least one course.
• 2. Partial Participation-
• It specifies that each entity in the entity set may or may not participate in
the relationship instance in that relationship set.
• That is why, it is also called as optional participation.
• Partial participation is represented using a single line between the entity
set and relationship set.
• Single line between the entity set “Course” and relationship set “Enrolled in”
signifies partial participation.
• It specifies that there might exist some courses for which no enrollments are
made.
Types of Attributes-
• Simple attributes
• Composite attributes
• Single valued attributes
• Multi valued attributes
• Derived attributes
• Key attributes
It is used for a bit-value type. The number of bits per value is specified in size. Its size
BIT(Size)
can be 1 to 64. The default value is 1.
It is used for the integer value. Its signed range varies from -2147483648 to 2147483647
INT(size) and unsigned range varies from 0 to 4294967295. The size parameter specifies the max
display width that is 255.
It is used to specify a floating point number. Its size parameter specifies the total number
FLOAT(size, d)
of digits. The number of digits after the decimal point is specified by d parameter.
It is a normal size floating point number. Its size parameter specifies the total number of
DOUBLE(size, d)
digits. The number of digits after the decimal is specified by d parameter.
Views
• Views in SQL are kind of virtual tables.
• A view also has rows and columns as they are in a real table in
the database.
• A View can either have all the rows of a table or specific rows
based on certain condition.
Example:
CREATE VIEW DetailsView AS SELECT NAME, ADDRESS
FROM StudentDetails WHERE S_ID < 5;
To see the data in the View, we can query the view in the same
manner as we query a table.
Delimiter /
Create procedure disp2(rn varchar(4))
Begin
Select * from emp where empid=rn;
End;
/
Execute it by - Call display2(1)/
Functions
• A function is same as a procedure except that it returns a value.
DELIMITER //
CREATE FUNCTION SQUARE (val INT)
RETURNS INT
BEGIN
DECLARE result INT;
SET result=0;
SET result=val * val;
RETURN result;
END; //
DELIMITER ;
Execute it by - Select square(2);
CREATE FUNCTION `employeelevel`(age int)
RETURNS varchar (20) DETERMINISTIC
BEGIN
declare employeelevel varchar(20);
if age>35 then
set employeelevel = 'seniour';
elseif (age<=35 and age>=30) then
set employeelevel = 'juniour';
elseif age<30 then
set employeelevel = 'fresher';
end if;
RETURN employeelevel;
END
Call function
select post, age, employeelevel(age) from employee;
Triggers
• Triggers are stored programs, which are automatically executed or fired
when some events occur.
Note: medicine table and neworder table should be created for operations.
Cursors
PL + SQL = PL/SQL
Advantages of NOSQL
7. Cheap and easy to implement due to open source.
8. Easy to distribute.
9. Scale to available memory.
10. Have individual query language rather than using a standard query.
11. Flexible data model
12. Developer friendly more developer centric interface.
NOSQL- MongoDB CRUD Operations
}
MongoDB GUI Tools
• NoSQLBooster
• Studio 3T
• MongoDB Compass
• Nucleon Database Master
• NoSQL Manager
• Mongo Management Studio
• MongoJS Query Analyzer
• Nosqlclient
• Cluster control
• Sql--- database--- table---rows---column---index
• Nosql---database---collection---documents—field---
index
• Collections
‘Collections’ in Mongo are equivalent to tables in relational databases. They
can hold multiple JSON documents.
• Documents
‘Documents’ are equivalent to records or rows of data in SQL.
• Fields
‘Fields’ or attributes are similar to columns in a SQL table.
• Schema
While Mongo is schema-less, SQL defines a schema via the table definition.
A Mongoose ‘schema’ is a document data structure (or shape of the
document) that is enforced via the application layer.
• Models
‘Models’ are higher-order constructors that take a schema and create an
instance of a document equivalent to records in a relational database.
CRUD Operation