You are on page 1of 20

Database Management

System
What is database? What are its objectives.
• A database is a collection of data that is organized and stored in a
structured way, typically in a computer system. The main objective of a
database is to provide a way to store and retrieve data efficiently and
accurately.
• Databases are used in a wide variety of applications, including business,
finance, healthcare, and education. They are particularly useful for storing
large amounts of data that needs to be accessed and updated frequently.
• There are several different types of databases, including relational
databases, object-oriented databases, and NoSQL databases. Each type of
database is designed to store and manage data in a specific way, and they
are used for different purposes depending on the needs of the application.
Some of the main objectives of a database include:
• Data storage: A database provides a central location for storing data, which makes it
easier to access and manage.
• Data organization: A database organizes data in a structured way, which makes it
easier to find and retrieve specific pieces of information.
• Data security: A database can include security measures to protect data from
unauthorized access or modification.
• Data integrity: A database can ensure that data is accurate and consistent, and it can
provide mechanisms for detecting and correcting errors.
• Data access: A database provides various ways to access and manipulate data,
including through SQL queries or other programming interfaces.
Overall, the main objective of a database is to provide a reliable and efficient way to
store and retrieve data, which is essential for many applications and businesses.
What is normalization?
• Normalization is the process of organizing a database in a way that
reduces redundancy and dependency, and improves the integrity and
efficiency of the data. Normalization is typically performed on
relational databases, which consist of tables with rows and columns
of data.

• There are several levels of normalization, known as normal forms,


which define different standards for organizing data. The three main
normal forms are:
• First normal form (1NF): A database is in 1NF if all the attributes
(columns) in a table are atomic, which means that they cannot be
divided into smaller pieces of data. In addition, each record (row) in
the table must be unique and contain no repeating groups of data.
• Second normal form (2NF): A database is in 2NF if it is already in 1NF
and all the non-key attributes (columns) in a table are dependent on
the primary key (a column or set of columns that uniquely identifies
each record in the table). This means that each non-key attribute
must be related to the primary key and cannot be determined by any
other attribute in the table.
• Third normal form (3NF): A database is in 3NF if it is already in 2NF
and there are no transitive dependencies (indirect relationships)
between non-key attributes. This means that all the attributes in a
table must be directly related to the primary key, and there can be no
dependencies between non-key attributes.
• Normalization is an important aspect of database design, as it helps
to ensure that the data is accurate, consistent, and efficient. It also
makes it easier to modify and update the database, as there are fewer
dependencies between different pieces of data.
Difference Between Centralized and
Distributed Database
• A centralized database is a single, central repository of data that is
shared among multiple users or systems. All data is stored in a single
location, and users can access and modify the data from any location
that has access to the database.

• A decentralized database, on the other hand, is a distributed system


of databases that are not centrally controlled. Each database is
independent and stores its own data, and users can access and
modify the data directly without going through a central server.
Database Models
• There are several different types of database models that are used to organize
and structure data in a database. Some of the most common database models
include:

• Relational database model: This is the most widely used database model, and it
organizes data into tables with rows and columns. Each row represents a record,
and each column represents an attribute of the record. Relationships between
different tables can be established using primary and foreign keys.

• Object-oriented database model: This database model is based on the object-


oriented programming paradigm, and it organizes data into objects that contain
both data and behavior. Objects in an object-oriented database can be related to
each other through inheritance and aggregation.
• Hierarchical database model: This database model organizes data into a tree-like structure, with a
single parent record and multiple child records. Each child record can have its own children,
creating a hierarchical structure.

• Network database model: This database model organizes data into a network of interconnected
records, with many-to-many relationships between records. Each record can be linked to multiple
other records, and each record can be a member of multiple sets.

• NoSQL database model: This is a broad category of database models that are designed for non-
relational data, such as unstructured or semi-structured data. NoSQL databases include
document databases, graph databases, and key-value stores.

• Each database model has its own strengths and weaknesses, and the choice of database model
depends on the needs of the application and the type of data being stored
What is ER Diagram?

• ER Diagram stands for Entity Relationship Diagram, also known as


ERD is a diagram that displays the relationship of entity sets stored in
a database. In other words, ER diagrams help to explain the logical
structure of databases. ER diagrams are created based on three basic
concepts: entities, attributes and relationships.
• ER Diagrams contain different symbols that use rectangles to
represent entities, ovals to define attributes and diamond shapes to
represent relationships.
Symbol Use in ER Diagaram
Example
Keys in DBMS
1. Primary Key
The primary key refers to a column or a set of columns of a table that helps us identify all the records uniquely present in that table. A
table can consist of just one primary key. Also, this primary key cannot consist of the same values reappearing/repeating for any of its
rows. All the values of a primary key have to be different, and there should be no repetitions.
The PK (PRIMARY KEY) constraint that we put on a column/set of columns won’t allow these to have a null value or a duplicate. Any
table can consist of only a single primary key constraint. A foreign key (explained below) that refers to it can never change the values
present in the primary key.
2. Super Key
A super key refers to the set of all those keys that help us uniquely identify all the rows present in a table. It means that all of these
columns present in a table that can identify the columns of that table uniquely act as the super keys.
A super key is a candidate key’s superset (candidate key has been explained below). We need to pick the primary key of any table
from the super key’s set so as to make it the table’s identity attribute.
3. Candidate Key
The candidate keys refer to those attributes that identify rows uniquely in a table. In a table, we select the primary key from a
candidate key. Thus, a candidate key has similar properties as that of the primary keys that we have explained above. In a table, there
can be multiple candidate keys.
4. Alternate Key
As we have stated above, any table can consist of multiple choices for the primary key. But, it can only choose
one. Thus, all those keys that did not become a primary key are known as alternate keys.
5. Foreign Key
We use a foreign key to establish relationships between two available tables. The foreign key would require
every value present in a column/set of columns to match the referential table’s primary key. A foreign key helps
us to maintain data as well as referential integrity.
6. Composite Key
The composite key refers to a set of multiple attributes that help us uniquely identify every tuple present in a
table. The attributes present in a set may not be unique whenever we consider them separately. Thus, when
we take them all together, it will ensure total uniqueness.
7. Unique Key
A unique key refers to a column/a set of columns that identify every record uniquely in a table. All the values in
this key would have to be unique. Remember that a unique key is different from a primary key. It is because it is
only capable of having one null value. A primary key, on the other hand, cannot have a null value.
SQL Queries Practise
• Insert
• Update
• Delete
• Select

• Please refer Teacher classes for basic query practical


• END

You might also like