1) Define normalization (1) (2)
1) Define normalization (1) (2)
types
First Normal Form (1st NF)
The table cells must be of a single value.
Eliminate repeating groups in individual tables.
Create a separate table for each set of related data.
Identify each set of related data with a primary key.
DBMS applications span various industries and systems. Four examples include:
banking and finance, healthcare, e-commerce, and education.
Ans- 1. Entity
2. Attribute
DBMS provides robust security features like user authentication and authorization, ensuring
only authorized users can access and modify data.
Streamlined Data Sharing:
DBMS allows authorized users to share data efficiently, improving collaboration and
reducing redundancy.
Improved Data Integrity:
DBMS enforces data integrity through constraints, ensuring data accuracy and consistency,
preventing invalid or duplicate information.
Efficient Data Retrieval and Management:
DBMS provides powerful tools for querying and manipulating data, making it easier for
users to access and manage information quickly and efficiently.
1) Explain ACID properties of transaction.
A – Atomicity
Atomicity means that an entire transaction either takes place all at once or it
doesn’t occur at all. It means that there’s no midway. The transactions can never
occur partially. Every transaction can be considered as a single unit, and they either
run to completion or do not get executed at all. We have the following two
operations here:
—Commit: In case a transaction commits, the changes made are visible to us. Thus,
atomicity is also called the ‘All or nothing rule’.
—Abort: In case a transaction aborts, the changes made to the database are not
visible to us.
C – Consistency
Consistency means that we have to maintain the integrity constraints so that any
given database stays consistent both before and after a transaction. If we refer to
the example discussed above, then we have to maintain the total amount, both
before and after the transaction.
Thus, the given database is consistent. Here, an inconsistency would occur when T1
completes, but then the T2 fails. As a result, the T would remain incomplete.
I – Isolation
D – Durability
The durability property states that once the execution of a transaction is completed,
the modifications and updates on the database gets written on and stored in the
disk. These persist even after the occurrence of a system failure. Such updates
become permanent and get stored in non-volatile memory. Thus, the effects of this
transaction are never lost.
DML stands for Data Manipulation Language. Tables and formulas are
helpful when communicating with data stored up to a point in a database
through SQL (Structured Query Language), but a time comes when we
actually want to execute some fairly complicated data interactions. We will
also need the Data Manipulation Language in that situation. DML is a way to
inform a database precisely what we want it to do by conversing in a manner
that it has been built to comprehend from scratch. When it comes to
interacting with existing data, whether adding, moving, or deleting data, it
provides a convenient way to do so.
SELECT Command-
This command is used to get data out of the database. It helps users of the
database to access from an operating system, the significant data they need.
It sends a track result set from one tables or more.
Syntax :
SELECT *
FROM <table_name>;
Example:
SELECT *
FROM students;
OR
SELECT *
FROM students
where due_fees <=20000;
INSERT Command
This command is used to enter the information or values into a row. We can
connect one or more records to a single table within a repository using this
instruction. This is often used to connect an unused tag to the documents.
Syntax:
Example :
UPDATE Command
Example:
UPDATE students
SET due_fees = 20000
WHERE stu_name = 'Mini';
DELETE Command
It deletes all archives from a table. This command is used to erase some or
all of the previous table’s records. If we do not specify the ‘WHERE’ condition
then all the rows would be erased or deleted.
Syntax:
Example:
In this article, we will discuss the overview of DDL commands and will
understand DDL commands like create, alter, truncate, drop. We will cover
each command syntax with the help of an example for better understanding.
Let’s discuss it one by one.
Overview :
Data Definition Language(DDL) is a subset of SQL and a part of
DBMS(Database Management System). DDL consist of Commands to
commands like CREATE, ALTER, TRUNCATE and DROP. These commands are
used to create or modify the tables in SQL.
CREATE :
This command is used to create a new table in SQL. The user has to give
information like table name, column names, and their datatypes.
Syntax –
CREATE TABLE table_name
(
column_1 datatype,
column_2 datatype,
column_3 datatype,
....
);
Example –
We need to create a table for storing Student information of a particular
College. Create syntax would be as below.
CREATE TABLE Student_info
(
College_Id number(2),
College_name varchar(30),
Branch varchar(10)
);
Command-2 :
ALTER :
This command is used to add, delete or change columns in the existing table.
The user needs to know the existing table name and can do add, delete or
modify tasks easily.
Syntax –
Syntax to add a column to an existing table.
ALTER TABLE table_name
ADD column_name datatype;
Example –
In our Student_info table, we want to add a new column for CGPA. The syntax
would be as below as follows.
ALTER TABLE Student_info
ADD CGPA number;
Command-3 :
TRUNCATE :
This command is used to remove all rows from the table, but the structure of
the table still exists.
Syntax –
Syntax to remove an existing table.
TRUNCATE TABLE table_name;
Example –
The College Authority wants to remove the details of all students for new
batches but wants to keep the table structure. The command they can use is
as follows.
TRUNCATE TABLE Student_info;
Command-4 :
DROP :
This command is used to remove an existing table along with its structure
from the Database.
Syntax –
Syntax to drop an existing table.
DROP TABLE table_name;
Example –
If the College Authority wants to change their Database by deleting the
Student_info Table.
DROP TABLE Student_info;
RENAME:
It is possible to change name of table with or without data in it using simple
RENAME command.
We can rename any table object at any point of time.
Syntax –RENAME TABLE <Table Name> To <New_Table_Name>;
Example: If you want to change the name of the table from Employee to Emp
we can use rename command as
RENAME TABLE Employee To EMP;
procedure or a package.
The Declaration section: Code block start with a declaration section, in
which memory variables, constants, cursors and other oracle objects can be
declared and if required initialized.
The Begin section: Consist of set of SQL and PL/SQL statements, which
describe processes that have to be applied to table data. Actual data
manipulation, retrieval, looping and branching constructs are specified in this
section.
The Exception section: This section deals with handling errors that arise
during execution data manipulation statements, which make up PL/SQL code
block. Errors can arise due to syntax, logic and/or validation rule.
The End section: This marks the end of a PL/SQL block.
Broadly, PL/SQL blocks are two types: Anonymous blocks and Named blocks
are as follows:
1. Anonymous blocks: In PL/SQL, That’s blocks which is not have header
are known as anonymous blocks. These blocks do not form the body of a
function or triggers or procedure. Example: Here a code example of find
greatest number with Anonymous blocks.
2. Named blocks: That’s PL/SQL blocks which having header or labels are
known as Named blocks. These blocks can either be subprograms like
functions, procedures, packages or Triggers. Example: Here a code example
of find greatest number with Named blocks means using function.
5) State the use of database trigger and also list types of
trigger.
Types of triggers:-
DML Triggers:
These are activated by events that modify data in a table, such as INSERT, UPDATE,
or DELETE operations.
DDL Triggers:
These are triggered by DDL events that alter the structure of the database, such as
CREATE, ALTER, or DROP statements.
Logon Triggers:
These are activated when a user logs into the database.
BEFORE and AFTER Triggers:
These triggers execute before or after the event that triggered them, respectively.
Statement-level and Row-level Triggers:
Statement-level triggers execute once per SQL statement, while row-level triggers
execute once for each row affected by the statement.
✅ Definition:
A Candidate Key is a column or a set of columns in a table that can uniquely identify
each record in that table.
There can be multiple candidate keys in a table, but only one of them is chosen as
the Primary Key.
✅ Characteristics:
✅ Example:
Student Nam
Email Phone
ID e
[email protected] 12345678
101 Alice
om 90
[email protected] 98765432
102 Bob
om 10
In this table:
✅ Definition:
A Foreign Key is a column (or group of columns) that creates a relationship between
two tables.
It refers to the primary key in another table to enforce referential integrity.
✅ Purpose:
Ensures the value in one table matches a valid value in another table.
Maintains consistency across related tables.
✅ Example:
Students Table:
Classes Table:
ClassI ClassNam
D e
Computer
10
Sci.
Mathematic
20
s
In this case, ClassID in the Students table is a Foreign Key that refers to
ClassID in the Classes table.
1. Count()
The COUNT() function returns the number of rows that match a given
condition or are present in a column.
COUNT(*): Counts all rows.
COUNT(column_name): Counts non-NULL values in the specified
column.
COUNT(DISTINCT column_name): Counts unique non-NULL values in
the column.
Examples:
-- Total number of records in the table
SELECT COUNT(*) AS TotalRecords FROM Employee;
2. SUM()
3. AVG()
The MIN() and MAX() functions return the smallest and largest values,
respectively, from a column.
MIN(column_name): Returns the minimum value.
MAX(column_name): Returns the maximum value.
Examples:
-- Find the highest salary
SELECT MAX(Salary) AS HighestSalary FROM Employee;
SQL joins are fundamental tools for combining data from multiple tables in
relational databases. Joins allow efficient data retrieval, which is essential
for generating meaningful observations and solving complex business
queries. Understanding SQL join types, such as INNER JOIN, LEFT JOIN,
RIGHT JOIN, FULL JOIN, and NATURAL JOIN, is critical for working with
relational databases.
In this article, we will cover the different types of SQL joins, including
INNER JOIN, LEFT OUTER JOIN, RIGHT JOIN, FULL JOIN, and NATURAL
JOIN. Each join type will be explained with examples, syntax, and practical
use cases to help us understand when and how to use these joins effectively.
SQL INNER JOIN
The INNER JOIN keyword selects all rows from both the tables as long as the
condition is satisfied. This keyword will create the result-set by combining
all rows from both the tables where the condition satisfies i.e value of the
common field will be the same.
Syntax
SELECT table1.column1,table1.column2,table2.column1,…. FROM table1
INNER JOIN table2 ON table1.matching_column = table2.matching_column;
Note: We can also write JOIN instead of INNER JOIN. JOIN is same as INNER
JOIN.
StudentCours
e Table
Let’s look at the example of INNER JOIN clause, and understand it’s
working. This query will show the names and age of students enrolled in
different courses.
Query:
Output
2. SQL LEFT JOIN
A LEFT JOIN returns all rows from the left table, along with matching rows
from the right table. If there is no match, NULL values are returned for
columns from the right table. LEFT JOIN is also known as LEFT OUTER JOIN.
Syntax
SELECT table1.column1,table1.column2,table2.column1,….
FROM table1
LEFT JOIN table2
ON table1.matching_column = table2.matching_column;
In this example, the LEFT JOIN retrieves all rows from the Student table
and the matching rows from the StudentCourse table based on the
ROLL_NO column.
Query:
SELECT Student.NAME,StudentCourse.COURSE_ID
FROM Student
LEFT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
RIGHT JOIN table2
ON table1.matching_column = table2.matching_column;
RIGHT JOIN Example
In this example, the RIGHT JOIN retrieves all rows from the StudentCourse
table and the matching rows from the Student table based on the ROLL_NO
column.
Query:
SELECT Student.NAME,StudentCourse.COURSE_ID
FROM Student
RIGHT JOIN StudentCourse
ON StudentCourse.ROLL_NO = Student.ROLL_NO;
Output
SELECT table1.column1,table1.column2,table2.column1,....
FROM table1
FULL JOIN table2
ON table1.matching_column = table2.matching_column;
9) List and explain advantages of DBMS over file
processing system
1. Query Processor
The query processing is handled by the query processor, as the name
implies. It executes the user's query, to put it simply. In this way, the query
processor aids the database system in making data access simple and easy.
The query processor's primary duty is to successfully execute the query.
Components of the Query Processor
DDL Interpreter:
Data Definition Language is what DDL stands for. As implied by the name,
the DDL Interpreter interprets DDL statements like those used in schema
definitions (such as create, remove, etc.). This interpretation yields a set of
tables that include the meta-data (data of data) that is kept in the data
dictionary.
DML Compiler:
Compiler for DML Data Manipulation Language is what DML stands for. In
keeping with its name, the DML Compiler converts DML statements like
select, update, and delete into low-level instructions or simply machine-
readable object code, to enable execution. The optimization of queries is
another function of the DML compiler.
2. Storage Manager:
An application called Storage Manager acts as a conduit between the queries
made and the data kept in the database. Another name for it is Database
Control System. By applying the restrictions and running the DCL
instructions, it keeps the database's consistency and integrity.
Integrity Manager:
Whenever there is any change in the database, the Integrity manager will
manage the integrity constraints.
Authorization Manager:
Authorization manager verifies the user that he is valid and authenticated for
the specific query or request.
File Manager:
All the files and data structure of the database are managed by this
component.
Transaction Manager:
It is responsible for making the database consistent before and after the
transactions. Concurrent processes are generally controlled by this
component.
Buffer Manager:
The transfer of data between primary and main memory and managing the
cache memory is done by the buffer manager.
3. Disk Storage
A DBMS can use various kinds of Data Structures as a part of physical system
implementation in the form of disk storage.
Data Dictionary:
It contains the metadata (data of data), which means each object of the
database has some information about its structure. So, it creates a
repository which contains the details about the structure of the database
object.
1. Implicit Cursors
n:=n-1;
end loop;
-- end loop
Sometimes, you might come across a situation where you need to revoke
For example, to withdraw all privileges for our non-root user we should use:
Finally, you can entirely delete an existing user account by using the
following command:
customer_id := &customer_id;
/* Validate customer ID */
IF customer_id <= 0 THEN
RAISE exception_invalid_id;
END IF;
EXCEPTION