DBMS Short Notes
DBMS Short Notes
What is DBMS?
The database management system (DBMS) is the software
that interacts with end-users, applications, and the
database itself to capture and analyse the data.
The DBMS software additionally encompasses the core
facilities provided to administer the database.
Database Languages
Data control language (DCL): It controls access to
data. It consists of commands GRANT, REVOKE.
Data definition language (DDL): It is used to define
database schema. It consists of SQL commands
CREATE, ALTER, DROP, etc.
Data manipulation language (DML): It is used to
perform tasks like inserting, deleting, updating data
occurrences. It consists of commands INSERT,
UPDATE, DELETE, etc.
Data query language (DQL): It allows searching for
information and computing derived information. It
consists of commands SELECT.
Relational Databases
A relational database is a database based on the relational
model of data.
Relational Algebra
Relational Algebra is considered a procedural query
language. It has a group of operators that work on relations
or tables. It takes relations as an input and also gives
relation as an output.
Keys in DBMS
Candidate Key - It is the minimal set of attributes that
can identify a tuple uniquely. A candidate key must
have a unique value in each row. A candidate key
can't have a NULL value in any row.
Super Key - Any number of attributes added to a
candidate key will be a super key.
Primary Key - A Primary Key is a set of attributes that
can uniquely identify the tuples. It is one of the
candidate keys which is most suitable to identify a
tuple. The value of the primary key in any row can't be
null. There can be only one primary key in a table.
Alternate Key - All other candidate keys except the
primary key are called Alternate Key.
Foreign Key - It is the set of attributes that establishes
a relationship between two tables.
Unique Key - It also identifies a tuple of a relation
uniquely. A table can have more than one unique key.
Normalization
Database Normalization is a technique that is used to
reduce redundancy or duplicate data from the database
and store the data logically. The main aim of Normalization
is any of the operations like insertion, deletion, and the
update of the data does not cause any anomalies.
Normal Forms
First Normal Form (1NF) - A relation is considered to
be in the first normal form if it doesn’t contain any
multivalued attribute.
Second Normal Form (2NF) - For a relation to be in
2NF, no non-prime attribute should be functionally
dependent on any partial candidate key or any proper
subset of the candidate key. There should be no
partial dependency. It must be in 1NF.
Third Normal Form (3NF) - For a table to be in 3NF,
there should be no transitive dependency for non-
prime attributes and it must be in 2NF. Transitive
dependency means indirect dependency like X→Y (Y is
dependent on X) and Y→Z so X→Z.
Boyce-Codd Normal Form (BCNF) - For a relation to be
in BCNF it must be in 3NF. For every non-trivial
functional dependency X→Y, X is a super key and for
every trivial functional dependency X→Y, Y is a subset
of X (Y⊆X). This form is stronger than 3NF.
Denormalization
Denormalization is a technique used to improve the
performance of a normalized database by adding some
redundant data.
Database Joins
Joins are used in relational databases to combine data from
multiple tables based on a common column between them.
A foreign key may be used to reference a row in another
table and join can be done based on those columns.
Database indexing
A database index is a data structure that improves the
speed of data retrieval operations on a database table at
the cost of additional writes and the use of more storage
space to maintain the extra copy of data. It enhances the
speed of accessing the data by minimizing the disk access
required each time when a query is processed.