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

Relational Model in DBMS Unit2

Uploaded by

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

Relational Model in DBMS Unit2

Uploaded by

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

Introduction to the Relational Model in DBMS

The Relational Model(RM) for database management is an approach to logically


represent and manage the data stored in a database. In this model, the data is organized into a
collection of two-dimensional inter-related tables, also known as relations. Each relation is a
collection of columns and rows, where the column represents the attributes of an entity and the
rows (or tuples) represents the records.

What is the Relational Model?


The relational model represents how data is stored in Relational Databases. A relational
database consists of a collection of tables, each of which is assigned a unique name. Consider
a relation STUDENT with attributes ROLL_NO, NAME, ADDRESS, PHONE, and AGE shown
in the table. Table Student

ROLL_NO NAME ADDRESS PHONE AGE

1 RAM DELHI 9455123451 18

2 RAMESH GURGAON 9652431543 18

3 SUJIT ROHTAK 9156253131 20

4 SURESH DELHI 18

Important Terminologies
 Attribute: Attributes are the properties that define an entity. e.g.; ROLL_NO, NAME,
ADDRESS
 Relation Schema: A relation schema defines the structure of the relation and represents
the name of the relation with its attributes. e.g.; STUDENT (ROLL_NO, NAME,
ADDRESS, PHONE, and AGE) is the relation schema for STUDENT. If a schema has
more than 1 relation, it is called Relational Schema.
 Tuple: Each row in the relation is known as a tuple. The above relation contains 4 tuples,
one of which is shown as:

1 RAM DELHI 9455123451 18

1
 Relation Instance: The set of tuples of a relation at a particular instance of time is called
a relation instance. Table 1 shows the relation instance of STUDENT at a particular time.
It can change whenever there is an insertion, deletion, or update in the database.
 Degree: The number of attributes in the relation is known as the degree of the relation.
The STUDENT relation defined above has degree 5.
 Cardinality: The number of tuples in a relation is known as cardinality.
The STUDENT relation defined above has cardinality 4.
 Column: The column represents the set of values for a particular attribute. The
column ROLL_NO is extracted from the relation STUDENT.

ROLL_NO

 NULL Values: The value which is not known or unavailable is called a NULL value. It is
represented by blank space. e.g.; PHONE of STUDENT having ROLL_NO 4 is NULL.

Terminologies used in Relation Model

 Tables: relations are saved in the table format. A table has two properties rows and
columns
 Attribute: columns represent as attributes
 Tuple: A Row represent as Tuple
 Relation Schema: A relation schema represents the name of the relation with its
attributes.
 Degree: The total number of attributes which in the relation is called the degree of the
relation.
 Cardinality: Total number of rows present in the Table.
 Column: The column represents the set of values for a specific attribute.
 Relation instance: The set of tuples of a relation at a particular instance of time is
called as relation instance.

Advantages of Realation Model


2
 Structural Independence: Structural independence is an ability that allows us to make
changes in one database structure without affecting other. The relational model have
structural independence. Hence making required changes in the database is convenient
in relational database model.

 Conceptual Simplicity: The relational model allows the designer to simply focus on
logical design and not on physical design. Hence relational models are conceptually
simple to understand.

 Query Capability: Using simple query language (such as SQL) user can get
information from the database or designer can manipulate the database structure.

 Easy design,maintenance and usage: The relational models can be designed


logically hence they are easy to maintain and use.

Disadvantages of Realation Model

 Relational model requires powerful hardware and large data storage devices.
 May lead to slower processing time.
 Poorly designed systems lead to poor implementation of database systems.

Integrity constraint over relations in DBMS


Integrity constraints are rules that help to maintain the accuracy and consistency of data in a
database. For example, a simple integrity constraint in DBMS might state that all students must
have a valid Roll Number. This would prevent someone from accidentally entering an invalid
roll number into the database.

Integrity constraints can also be used to enforce relationships between tables. For example, if a
student can only have one aadhaar number, then an integrity constraint can be used to ensure
that only one aadhaar number is entered for each student.

Different types of Integrity Constraints


 Domain Constraint
 Entity Integer Constraint
 Referential Integrity Constraint
 Key Constraints

Domain Constraint

3
A domain constraint is a restriction on the values that can be stored in a column.
Strings, character, time, integer, currency, date etc. Are examples of the data type of domain
constraints.

example, if you have a column for "age" domain integrity constraints in DBMS would ensure
that only integer values can be entered into that column. This ensures that only valid data is
entered into the database.

These are attribute-level constraints. An attribute can only take values that lie inside the
domain range. e.g.; If a constraint AGE>0 is applied to STUDENT relation, inserting a
negative value of AGE will result in failure.

Example-
Consider the following Student table-

STU_ID Name Age

S001 Akshay 20

S002 Abhishek 21

S003 Shashank 20

S004 Rahul A

Here, value ‘A’ is not allowed since only integer values can be taken by the age attribute.

Entity Integer Constraint


Entity integrity constraints would ensure that null values are not entered into any
required columns. It states that primary key value can't be null. This is because the primary key
value is used to identify individual rows in relation and if the primary key has a null value, then
we can't identify those rows

For example, if you have a column for ”STU_ID" an entity integrity constraint in DBMS
would ensure that this column cannot contain any null values.

4
Every relation in the database should have at least one set of attributes that defines a
tuple uniquely. Those set of attributes is called keys. e.g.; STU_ID in STUDENT is key. No
two students can have the same roll number. So a key has two properties:

 It should be unique for all tuples.

 It can’t have NULL values.

Referential Integrity Constraint


A referential integrity constraint is a restriction on how foreign keys can be used. A
foreign key is a column in one table that references a primary key in another table.

For example, let's say you have a table of Students and a table of Marks. The "roll_number"
column in the Marks table would be a foreign key that references the "roll_number" column in
the Students table.

When one attribute of a relation can only take values from another attribute of the
same relation or any other relation, it is called referential integrity. Let us suppose we have 2
relations
Table Student

ROLL_NO NAME ADDRESS PHONE AGE BRANCH_CODE

1 RAM DELHI 9455123451 18 CS

2 RAMESH GURGAON 9652431543 18 CS

3 SUJIT ROHTAK 9156253131 20 ECE

4 SURESH DELHI 18 IT

5 NARESH MIRYALGUDA 966622006 21 AIML

Table Branch

5
BRANCH_CODE BRANCH_NAME

CS COMPUTER SCIENCE

IT INFORMATION TECHNOLOGY

ELECTRONICS AND COMMUNICATION


ECE
ENGINEERING

CV CIVIL ENGINEERING

BRANCH_CODE of STUDENT can only take the values which are present in
BRANCH_CODE of BRANCH which is called referential integrity constraint. The relation
which is referencing another relation is called REFERENCING RELATION (STUDENT in this
case) and the relation to which other relations refer is called REFERENCED RELATION
(BRANCH in this case).

CREATE TABLE table_name (


column1 datatype,
column2 datatype,
column3 datatype,
....
FOREIGN KEY (column) REFERENCES table_name1(column)
);

Here,

 The relation ‘Student’ does not satisfy the referential integrity constraint.
 This is because in relation ‘BRANCH_CODE’, no value of primary key specifies
department AIML.
 Thus, referential integrity constraint is violated.

Key Constraints

6
From above employee table john monthly salary is hike. But from above table total 3 names
started with the name john. now data base confuse which record is update among three
starting with the name john. That why we need one unique id (primary key).

A key constraint is a rule that defines how data in a column(s) can be stored in a table. A key is
composed of one or more columns whose values uniquely identify each row in the table. There
are several different types of key constraints in DBMS, each with its own specific purpose.

7
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.

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 below. In a table,
there can be multiple candidate keys.

Primary Key

8
The primary key refers to a column of a table that helps us identify all the records
uniquely present in that table. Any table can consist of only a single primary key
constraint. values of a primary key won’t allow null value or a duplicate values.
Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
CONSTRAINT constraint_name PRIMARY KEY(column)
);

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.

9
Unique Key
A unique key refers to a column or a set of columns that identify every record uniquely
in a table. All the values in this key would have to be unique. values of a unique key
won’t allow duplicate values and it is only capable of having one null value.

Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
UNIQUE (column)
);

10
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.

Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
CONSTRAINT constraint_name UNIQUE(column,column)
);

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.

11
Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
CONSTRAINT constraint_name FOREIGN KEY (column)
REFERENCES table_name1(column)
);

CHECK Constraint
The CHECK constraint is used to limit the value range that can be placed in a column.
If you define a CHECK constraint on a column it will allow only certain values for this
column. If you define a CHECK constraint on a table it can limit the values in certain
columns based on values in other columns in the row.
Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype,
column3 datatype,
....
CONSTRAINT constraint_name CHECK (condition)
);

Example:

12
CREATE TABLE students (
ID int,
LastName varchar(30),
FirstName varchar(30),
Age int,
CONSTRAINT con_age CHECK (Age>=18)
);

DEFAULT Constraint
The DEFAULT constraint is used to set a default value for a column. The default value
will be added to all new records, if no other value is specified.
The DEFAULT constraint can also be used to insert system date, by using functions
like GETDATE().
Syntax in Mysql
CREATE TABLE table_name (
column1 datatype,
column2 datatype DEFAULT 'value',
column3 datatype DEFAULT GETDATE(),
....
);

Example:
CREATE TABLE students (
ID int,
LastName varchar(30),
FirstName varchar(30),
Age int DEFAULT 18,
joining_date DEFAULT GETDATE()
);

Advantages of the Relational Model


 Simple model: Relational Model is simple and easy to use in comparison to
other languages.
 Flexible: Relational Model is more flexible than any other relational model
present.
 Secure: Relational Model is more secure than any other relational model.
 Data Accuracy: Data is more accurate in the relational data model.
 Data Integrity: The integrity of the data is maintained in the relational
model.
13
 Operations can be Applied Easily: It is better to perform operations in the
relational model.
Disadvantages of the Relational Model
 Relational Database Model is not very good for large databases.
 Sometimes, it becomes difficult to find the relation between tables.
 Because of the complex structure, the response time for queries is high.
Characteristics of the Relational Model
 Data is represented in rows and columns called relations.
 Data is stored in tables having relationships between them called the
Relational model.
 The relational model supports the operations like Data definition, Data
manipulation, and Transaction management.
 Each column has a distinct name and they are representing attributes.
 Each row represents a single entity.

Querying Relational Data in DBMS

SELECT Statement
The SELECT statement is the most commonly used command in Structured Query
Language. It is used to access the records from one or more database tables and views.
It also retrieves the selected data that follow the conditions we want.

By using this command, we can also access the particular record from the particular
column of the table. The table which stores the record returned by the SELECT
statement is called a result-set table.

Syntax of SELECT Statement in SQL

1. SELECT Column_Name_1, Column_Name_2, ....., Column_Name_N FROM Table_


Name;

In this SELECT syntax, Column_Name_1, Column_Name_2, ….., Column_Name_N are


the name of those columns in the table whose data we want to read.

14
If you want to access all rows from all fields of the table, use the following SQL SELECT
syntax with * asterisk sign:

1. SELECT * FROM table_name;

Examples of SELECT Statement in SQL


Here, we took the following two different SQL examples which will help you to execute
the SELECT statement for retrieving the records:

Example 1:

Firstly, we have to create the new table and then insert some dummy records into it.

Use the following query to create the Student_Records table in SQL:

1. CREATE TABLE Student_Records


2. (
3. Student_Id Int PRIMARY KEY,
4. First_Name VARCHAR (20),
5. Address VARCHAR (20),
6. Age Int NOT NULL,
7. Percentage Int NOT NULL,
8. Grade VARCHAR (10)
9. ) ;

The following query inserts the record of intelligent students into


the Student_Records table:

1. INSERT INTO Student VALUES (201, Akash, Delhi, 18, 89, A2),
2. (202, Bhavesh, Kanpur, 19, 93, A1),
3. (203, Yash, Delhi, 20, 89, A2),
4. (204, Bhavna, Delhi, 19, 78, B1),
5. (05, Yatin, Lucknow, 20, 75, B1),
6. (206, Ishika, Ghaziabad, 19, 51, C1),
7. (207, Vivek, Goa, 20, 62, B2);

The following SQL query displays all the values of each column from the above
Student_records table:

1. SELECT * FROM Student_Records;

15
The output of the above query is:

Student_ID First_Name Address Age Percentage Grade

201 Akash Delhi 18 89 A2

202 Bhavesh Kanpur 19 93 A1

203 Yash Delhi 20 89 A2

204 Bhavna Delhi 19 78 B1

205 Yatin Lucknow 20 75 B1

206 Ishika Ghaziabad 19 91 C1

207 Vivek Goa 20 80 B2

Example 2:

The following query displays the values of particular column from the
above Student_Record table:

1. SELECT Student_Id, Age, Percentage, Grade FROM Employee;

Student_ID Age Percentage Grade

201 18 89 A2

202 19 93 A1

203 20 89 A2

204 19 78 B1

205 20 75 B1

206 19 91 C1

207 20 80 B2

SELECT Statement with WHERE clause

16
The WHERE clause is used with SELECT statement to return only those rows from the
table, which satisfy the specified condition in the query.

In SQL, the WHERE clause is not only used with SELECT, but it is also used with other
SQL statements such as UPDATE, ALTER, and DELETE statements.

Syntax of SELECT Statement with WHERE clause

1. SELECT * FROM Name_of_Table WHERE [condition];

In the syntax, we specify the condition in the WHERE clause using SQL logical or
comparison operators.

Example of SELECT Statement with WHERE clause

Firstly, we have to create the new table and then insert some dummy records into it.

Use the following query to create the Employee_Details table in SQL:

1. CREATE TABLE Employee_Details


2. (
3. Employee_ID INT AUTO_INCREMENT PRIMARY KEY,
4. Emp_Name VARCHAR (50),
5. Emp_City VARCHAR (20),
6. Emp_Salary INT NOT NULL,
7. Emp_Panelty INT NOT NULL
8. ) ;

The following INSERT query inserts the record of employees into the Employee_Details
table:

1. INSERT INTO Employee_Details (Employee_ID, Emp_Name, Emp_City, Emp_Salar


y, Emp_Panelty) VALUES (101, Anuj, Ghaziabad, 25000, 500),
2. (102, Tushar, Lucknow, 29000, 1000),
3. (103, Vivek, Kolkata, 35000, 500),
4. (104, Shivam, Goa, 22000, 500);

The following SELECT query shows the data of the Employee_Details table:

1. SELECT * FROM Employee_Details;

17
Employee_Id Emp_Name Emp_City Emp_Salary Emp_Panelty

101 Anuj Ghaziabad 25000 500

102 Tushar Lucknow 29000 1000

103 Vivek Kolkata 35000 500

104 Shivam Goa 22000 500

The following query shows the record of those employees from the above table whose
Emp_Panelty is 500:

1. SELECT * FROM Employee_Details WHERE Emp_Panelty = 500;

This SELECT query displays the following table in result:

Employee_Id Emp_Name Emp_City Emp_Salary Emp_Panelty

101 Anuj Ghaziabad 25000 500

103 Vivek Kolkata 35000 500

104 Shivam Goa 22000 500

SQL SELECT Statement with GROUP BY


clause
The GROUP BY clause is used with the SELECT statement to show the common data of
the column from the table:

Syntax of SELECT Statement with GROUP BY clause

1. SELECT column_Name_1, column_Name_2, ....., column_Name_N aggregate_func


tion_name(column_Name2) FROM table_name GROUP BY column_Name1;

Example of SELECT Statement with GROUP BY clause

Use the following query to create the Cars_Details table:

1. CREATE TABLE Cars_Details


2. (

18
3. Car_Number INT PRIMARY KEY,
4. Car_Name VARCHAR (50),
5. Car_Price INT NOT NULL,
6. Car_AmountINT NOT NULL
7. ) ;

The following INSERT query inserts the record of cars into the Cars_Details table:

1. INSERT INTO Cars_Details (Car_Number, Car_Name, Car_Amount, Car_Price)


2. VALUES (2578, Creta, 3, 1500000),
3. (9258, Audi, 2, 3000000),
4. (8233, Venue, 6, 900000),
5. (6214, Nexon, 7, 1000000);

The following SELECT query displays the values in the output:

1. SELECT * FROM Cars_Details;

Car_Number Car_Name Car_Amount Car_Price

2578 Creta 3 1000000

9258 Audi 2 900000

8233 Venue 6 900000

6214 Nexon 7 1000000

The following SELECT with GROUP BY query lists the number of cars of the same price:

1. SELECT COUNT (Car_Name), Car_Price FROM Cars_Details GROUP BY Car_Price;

The output of above GROUP BY query is shown below:

Output:

Count (Car_Name) Car_Price

2 1000000

2 900000

19
SQL SELECT Statement with HAVING clause
The HAVING clause in the SELECT statement creates a selection in those groups which
are defined by the GROUP BY clause.

Syntax of SELECT Statement with HAVING clause

1. SELECT column_Name_1, column_Name_2, ....., column_Name_N aggregate_func


tion_name(column_Name_2) FROM table_name GROUP BY column_Name1 HA
VING ;

Example of SELECT Statement with HAVING clause

Let's create the Employee_Having table in SQL using the below CREATE command:

1. CREATE TABLE Employee_Having


2. (
3. Employee_Id INT PRIMARY KEY,
4. Employee_Name VARCHAR (50),
5. Employee_Salary INT NOT NULL,
6. Employee_City VARCHAR (50)
7. ) ;

The following INSERT query inserts the record of employees into the Employee_Having
table:

1. INSERT INTO Employee_Having (Employee_Id, Employee_Name, Employee_Salar


y, Employee_City)
2. VALUES (201, Jone, 20000, Goa),
3. (202, Basant, 40000, Delhi),
4. (203, Rashet, 80000,Jaipur),
5. (204, Aunj, 20000, Goa),
6. (205, Sumit, 50000, Delhi);

The following SELECT query shows the values of Employee_Having table in the output:

1. SELECT * FROM Employee_Having;

Employee_Id Employee_Name Employee_Salary Employee_City

20
201 Jone 20000 Goa

202 Basant 40000 Delhi

203 Rashet 80000 Jaipur

204 Anuj 20000 Goa

205 Sumit 50000 Delhi

The following query shows the total salary of those employees having more than 5000
from the above Employee_Having table:

1. SELECT SUM (Employee_Salary), Employee_City FROM Employee_Having GROU


P BY Employee_City HAVING SUM(Employee_Salary)>50000;

This HAVING query with SELECT statement shows the following table:

Output:

SUM (Employee_Salary) Employee_City

90000 Delhi

80000 Jaipur

SELECT Statement with ORDER BY clause


The ORDER BY clause with the SQL SELECT statement shows the records or rows in a
sorted manner.

The ORDER BY clause arranges the values in both ascending and descending order. Few
database systems arrange the values of column in ascending order by default.

Syntax of SELECT Statement with ORDER BY clause

1. SELECT Column_Name_1, Column_Name_2, ....., column_Name_N FROM table_n


ame WHERE [Condition] ORDER BY[column_Name_1, column_Name_2, ....., colu
mn_Name_N asc | desc ];

Example of SELECT Statement with ORDER BY clause in SQL

1. CREATE TABLE Employee_Order


21
2. (
3. Id INT NOT NULL,
4. FirstName VARCHAR (50),
5. Salary INT,
6. City VARCHAR (50)
7. ) ;

The following INSERT query inserts the record of employees into the Employee_Having
table:

1. INSERT INTO Employee_Order (Id, FirstName, Salary, City)


2. VALUES (201, Jone, 20000, Goa),
3. (202, Basant, 15000, Delhi),
4. (203, Rashet, 80000,Jaipur),
5. (204, Aunj, 90000, Goa),
6. (205, Sumit, 50000, Delhi);

The following SELECT query shows the values of the table in the output:

1. SELECT * FROM Employee_Order;

Id FirstName Salary City

201 Jone 20000 Goa

202 Basant 15000 Delhi

203 Rashet 80000 Jaipur

204 Anuj 90000 Goa

205 Sumit 50000 Delhi

The following query sorts the salary of employees in descending order from the above
Employee_Order table:

1. SELECT * FROM Employee_Order ORDER BY Emp_Salary DESC;

This SQL query shows the following table in result:

Output:

22
Emp_Id Emp_Name Emp_Salary Emp_City

204 Anuj 90000 Goa

203 Rashet 80000 Jaipur

205 Sumit 50000 Delhi

201 Jone 20000 Goa

202 Basant 15000 Delhi

Logical Database


A Logical Database is a special type of ABAP (Advance Business Application and


Programming) that is used to retrieve data from various tables and the data is interrelated
to each other. Also, a logical database provides a read-only view of Data.
Structure Of Logical Database:
A Logical database uses only a hierarchical structure of tables i.e. Data is organized in a
Tree-like Structure and the data is stored as records that are connected to each other
through edges (Links). Logical Database contains Open SQL statements which are used
to read data from the database. The logical database reads the program, stores them in
the program if required, and passes them line by line to the application program.

23
Features of Logical Database:
In this section, let us look at some features of a logical database:
 We can select only that type of Data that we need.
 Data Authentication is done in order to maintain security.
 Logical Database uses hierarchical Structure due to this data integrity is
maintained.
Goal Of Logical Database:
The goal of Logical Database is to create well-structured tables that reflect the
need of the user. The tables of the Logical database store data in a non-
redundant manner and foreign keys will be used in tables so that relationships
among tables and entities will be supported.
Tasks Of Logical Database:
Below is some important task of Logical Database:
 With the help of the Logical database, we will read the same data from
multiple programs.
 A logical database defines the same user interface for multiple programs.
 Logical Database ensures the Authorization checks for the centralized
sensitive database.
 With the help of a Logical Database, Performance is improved. Like in
Logical Database we will use joins instead of multiple SELECT statements,
which will improve response time and this will increase the Performance of
Logical Database.

24
Data View Of Logical Database:
Logical Database provides a particular view of Logical Database tables. A
logical database is appropriately used when the structure of the Database is
Large. It is convenient to use flow i.e
 SELECT
 READ
 PROCESS
 DISPLAY
In order to work with databases efficiently. The data of the Logical Database is
hierarchical in nature. The tables are linked to each other in a Foreign Key
relationship.
Diagrammatically, the Data View of Logical Database is shown as: Tables must
have Foreign Key Relationship.
 A logical Database consists of logically related tables that are arranged in a
hierarchical manner used for reading or retrieving Data.
 Logical Database consist of three main elements:
 Structure of Database
 Selections of Data from Database
 Database Program
 If we want to improve the access time on data, then we use VIEWS in
Logical Database.
Example:
Suppose in a University or College, a HOD wants to get information about a
specific student. So for that, he firstly retrieves the data about its batch and
Branch from a large amount of Data, and he will easily get information about
the required Student but didn’t alter the information about it.
Advantages Of Logical Database:
Let us look at some advantages of the logical database:
 In a Logical database, we can select meaningful data from a large amount
of data.
 Logical Database consists of Central Authorization which checks for
Database Accesses is Authenticated or not.
 In this Coding, the part is less required to retrieve data from the database as
compared to Other Databases.
 Access performance of reading data from the hierarchical structure of the
Database is good.
 Easy to understand user interfaces.
 Logical Database firstly check functions which further check that user input
is complete, correct, and plausible.

25
Disadvantages Of Logical Database:
This section shows the disadvantages of the logical database:
 Logical Database takes more time when the required data is at the last
because if that table which is required at the lowest level then firstly all
upper-level tables should be read which takes more time and this slows
down the performance.
 In Logical Database ENDGET command doesn’t exist due to this the code
block associated with an event ends with the next event statement.

Views in SQL
A view is generated to show the information that the end-user requests the data
according to specified needs rather than complete information of the table.

Advantages of View over


database tables
 Using Views, we can join multiple tables into a single virtual table.

 Views hide data complexity.

 In the database, views take less space than tables for storing data
because the database contains only the view definition.

 Views indicate the subset of that data, which is contained in the


tables of the database.

Creating Views

Database views are created using the CREATE VIEW statement. Views can be
created from a single table, multiple tables or another view.
To create a view, a user must have the appropriate system privilege according to
the specific implementation.

Syntax in Mysql
26
CREATE VIEW view_name AS

SELECT column1, column2, ...

FROM table_name

WHERE condition;

Example:

CREATE VIEW Students_CSE AS


SELECT Roll_no,Name
FROM Students
WHERE Branch = 'CSE';

Updating a View

A view can be updated with the CREATE OR REPLACE VIEW statement.

Syntax in Mysql

CREATE OR REPLACE VIEW view_name AS

SELECT column1, column2, ...

FROM table_name

WHERE condition;

The following SQL adds the "Mobile" column to the "Students_CSE" view:

Example:

CREATE OR REPLACE VIEW Students_CSE AS


SELECT Roll_no,Name,Mobile
27
FROM Students
WHERE Branch = 'CSE';
CREATE VIEW defines a view on a set of tables or views or both.
REPLACE VIEW redefines an existing view or, if the specified view does not
exist,

Inserting a row in a view

We can insert a row in a View in a same way as we do in a table. We can use the
INSERT INTO statement of SQL to insert a row in a View.

Syntax in Mysql

INSERT INTO view_name(column1, column2, ...)

VALUES(value1,value2,.....);

Example:

INSERT INTO Students_CSE(Roll_no,Name,Mobile)


VALUES(521,'ram',9988776655);

Deleting a row in a view

Deleting rows from a view is also as simple as deleting rows from a table. We can
use the DELETE statement of SQL to delete rows from a view.

Syntax in Mysql
28
DELETE FROM view_name

WHERE condition;

Example:

DELETE FROM Students_CSE


WHERE Name="ram";

Querying a View

We can query the view as follows

Syntax in Mysql

SELECT * FROM view_name

Example:

SELECT * FROM Students_CSE;

Dropping a View

In order to delete a view in a database, we can use the DROP VIEW statement.

Syntax in Mysql

DROP FROM view_name

29
Example:

DROP FROM Students_CSE;

o Views in SQL are considered as a virtual table. A view also contains rows and
columns.
o To create the view, we can select the fields from one or more tables present in
the database.
o A view can either have specific rows based on certain condition or all the rows of
a table.

Student_Detail

STU_ID NAME ADDRESS

1 Stephan Delhi

2 Kathrin Noida

3 David Ghaziabad

4 Alina Gurugram

Student_Marks

STU_ID NAME MARKS AGE

1 Stephan 97 19

2 Kathrin 86 21

3 David 74 18

4 Alina 90 20

5 John 96 18

1. Creating view
30
A view can be created using the CREATE VIEW statement. We can create a view from a
single table or multiple tables.

Syntax:

1. CREATE VIEW view_name AS


2. SELECT column1, column2.....
3. FROM table_name
4. WHERE condition;

2. Creating View from a single table


In this example, we create a View named DetailsView from the table Student_Detail.

Query:

1. CREATE VIEW DetailsView AS


2. SELECT NAME, ADDRESS
3. FROM Student_Details
4. WHERE STU_ID < 4;

Just like table query, we can query the view to view the data.

1. SELECT * FROM DetailsView;

Output:

NAME ADDRESS

Stephan Delhi

Kathrin Noida

David Ghaziabad

3. Creating View from multiple tables


View from multiple tables can be created by simply include multiple tables in the
SELECT statement.

In the given example, a view is created named MarksView from two tables
Student_Detail and Student_Marks.

31
Query:

1. CREATE VIEW MarksView AS


2. SELECT Student_Detail.NAME, Student_Detail.ADDRESS, Student_Marks.MARKS
3. FROM Student_Detail, Student_Mark
4. WHERE Student_Detail.NAME = Student_Marks.NAME;

To display data of View MarksView:

1. SELECT * FROM MarksView;

NAME ADDRESS MARKS

Stephan Delhi 97

Kathrin Noida 86

David Ghaziabad 74

Alina Gurugram 90

4. Deleting View
A view can be deleted using the Drop View statement.

Syntax

1. DROP VIEW view_name;

Example:

If we want to delete the View MarksView, we can do this as:

1. DROP VIEW MarksView

32
DBMS Relational Algebra
Types of operations in relational algebra
We have divided these operations in two categories:
1. Basic Operations
2. Derived Operations

Basic/Fundamental Operations:
1. Select (σ)
2. Project (∏)
3. Union (∪)
4. Set Difference (-)
5. Cartesian product (X)
6. Rename (ρ)

Derived Operations:
1. Natural Join (⋈)
2. Left, Right, Full outer join (⟕, ⟖, ⟗)
3. Intersection (∩)
4. Division (÷)

Lets discuss these operations one by one with the help of examples.

Select Operator (σ)


Select Operator is denoted by sigma (σ) and it is used to find the tuples (or rows) in a
relation (or table) which satisfy the given condition.

If you understand little bit of SQL then you can think of it as a where clause in SQL,
which is used for the same purpose.

Syntax of Select Operator (σ)

σ Condition/Predicate(Relation/Table name)

Select Operator (σ) Example


Table: CUSTOMER
---------------

Customer_IdCustomer_NameCustomer_City
----------- ------------- -------------
33
C10100 SteveAgra
C10111 RaghuAgra
C10115 ChaitanyaNoida
C10117 AjeetDelhi
C10118 CarlDelhi
Query:

σ Customer_City="Agra" (CUSTOMER)
Output:

Customer_IdCustomer_NameCustomer_City
----------- ------------- -------------
C10100 SteveAgra
C10111 RaghuAgra

Project Operator (∏)


Project operator is denoted by ∏ symbol and it is used to select desired columns (or
attributes) from a table (or relation).

Project operator in relational algebra is similar to the Select statement in SQL.

Syntax of Project Operator (∏)

∏ column_name1, column_name2, ...., column_nameN(table_name)


Project Operator (∏) Example
In this example, we have a table CUSTOMER with three columns, we want to fetch only
two columns of the table, which we can do with the help of Project Operator ∏.

Table: CUSTOMER

Customer_IdCustomer_NameCustomer_City
----------- ------------- -------------
C10100 SteveAgra
C10111 RaghuAgra
C10115 ChaitanyaNoida
C10117 AjeetDelhi
C10118 CarlDelhi
Query:

∏ Customer_Name, Customer_City (CUSTOMER)


Output:

Customer_NameCustomer_City
------------- -------------
SteveAgra

34
RaghuAgra
ChaitanyaNoida
AjeetDelhi
CarlDelhi

Union Operator (∪)


Union operator is denoted by ∪ symbol and it is used to select all the rows (tuples) from
two tables (relations).

Lets discuss union operator a bit more. Lets say we have two relations R1 and R2 both
have same columns and we want to select all the tuples(rows) from these relations then
we can apply the union operator on these relations.

Note: The rows (tuples) that are present in both the tables will only appear once in the
union set. In short you can say that there are no duplicates present after the union
operation.

Syntax of Union Operator (∪)

table_name1 ∪ table_name2

Union Operator (∪) Example


Table 1: COURSE

Course_IdStudent_NameStudent_Id
--------- ------------ ----------
C101 Aditya S901
C104 Aditya S901
C106 Steve S911
C109 Paul S921
C115 Lucy S931
Table 2: STUDENT

Student_IdStudent_NameStudent_Age
------------ ---------- -----------
S901 Aditya19
S911 Steve18
S921 Paul19
S931 Lucy17
S941 Carl16
S951 Rick18
Query:

∏ Student_Name (COURSE) ∪ ∏ Student_Name (STUDENT)


Output:

35
Student_Name
------------
Aditya
Carl
Paul
Lucy
Rick
Steve
Note: As you can see there are no duplicate names present in the output even though we
had few common names in both the tables, also in the COURSE table we had the
duplicate name itself.

Intersection Operator (∩)


Intersection operator is denoted by ∩ symbol and it is used to select common rows
(tuples) from two tables (relations).

Lets say we have two relations R1 and R2 both have same columns and we want to
select all those tuples(rows) that are present in both the relations, then in that case we
can apply intersection operation on these two relations R1 ∩ R2.

Note: Only those rows that are present in both the tables will appear in the result set.

Syntax of Intersection Operator (∩)

table_name1 ∩ table_name2
Intersection Operator (∩) Example
Lets take the same example that we have taken above.
Table 1: COURSE

Course_IdStudent_NameStudent_Id
--------- ------------ ----------
C101 Aditya S901
C104 Aditya S901
C106 Steve S911
C109 Paul S921
C115 Lucy S931
Table 2: STUDENT

Student_IdStudent_NameStudent_Age
------------ ---------- -----------
S901 Aditya19
S911 Steve18
S921 Paul19
S931 Lucy17
S941 Carl16

36
S951 Rick18
Query:

∏ Student_Name (COURSE) ∩ ∏ Student_Name (STUDENT)


Output:

Student_Name
------------
Aditya
Steve
Paul
Lucy

Set Difference (-)


Set Difference is denoted by – symbol. Lets say we have two relations R1 and R2 and
we want to select all those tuples(rows) that are present in Relation R1 but not present in
Relation R2, this can be done using Set difference R1 – R2.

Syntax of Set Difference (-)

table_name1 - table_name2
Set Difference (-) Example
Lets take the same tables COURSE and STUDENT that we have seen above.

Query:
Lets write a query to select those student names that are present in STUDENT table but
not present in COURSE table.

∏ Student_Name (STUDENT) - ∏ Student_Name (COURSE)


Output:

Student_Name
------------
Carl
Rick

Cartesian product (X)


Cartesian Product is denoted by X symbol. Lets say we have two relations R1 and R2
then the cartesian product of these two relations (R1 X R2) would combine each tuple of
first relation R1 with the each tuple of second relation R2. I know it sounds confusing
but once we take an example of this, you will be able to understand this.

Syntax of Cartesian product (X)


37
R1 X R2
Cartesian product (X) Example
Table 1: R

Col_ACol_B
----- ------
AA 100
BB 200
CC 300
Table 2: S

Col_XCol_Y
----- -----
XX 99
YY 11
ZZ 101
Query:
Lets find the cartesian product of table R and S.

R X S
Output:

Col_ACol_BCol_XCol_Y
----- ------ ------ ------
AA 100 XX 99
AA 100 YY 11
AA 100 ZZ 101
BB 200 XX 99
BB 200 YY 11
BB 200 ZZ 101
CC 300 XX 99
CC 300 YY 11
CC 300 ZZ 101
Note: The number of rows in the output will always be the cross product of number of
rows in each table. In our example table 1 has 3 rows and table 2 has 3 rows so the
output has 3×3 = 9 rows.

Rename (ρ)
Rename (ρ) operation can be used to rename a relation or an attribute of a relation.
Rename (ρ) Syntax:
ρ(new_relation_name, old_relation_name)

Rename (ρ) Example

38
Lets say we have a table customer, we are fetching customer names and we are renaming
the resulted relation to CUST_NAMES.

Table: CUSTOMER

Customer_IdCustomer_NameCustomer_City
----------- ------------- -------------
C10100 SteveAgra
C10111 RaghuAgra
C10115 ChaitanyaNoida
C10117 AjeetDelhi
C10118 CarlDelhi
Query:

ρ(CUST_NAMES, ∏(Customer_Name)(CUSTOMER))
Output:

CUST_NAMES
----------
Steve
Raghu
Chaitanya
Ajeet
Carl

DBMS Relational Calculus


What is Relational Calculus?
Relational calculus is a non-procedural query language that tells the system what data to
be retrieved but doesn’t tell how to retrieve it.

Types of Relational Calculus

39
1. Tuple Relational Calculus (TRC)
Tuple relational calculus is used for selecting those tuples that satisfy the given
condition.
Table: Student

First_NameLast_NameAge
-----------------------
AjeetSingh30
ChaitanyaSingh31
RajeevBhatia27
CarlPratap28
Lets write relational calculus queries.

Query to display the last name of those students where age is greater than 30

{t.Last_Name|Student(t) AND t.age>30}


In the above query you can see two parts separated by | symbol. The second part is
where we define the condition and in the first part we specify the fields which we want
to display for the selected tuples.

The result of the above query would be:

Last_Name
---------
Singh
Query to display all the details of students where Last name is ‘Singh’

{ t|Student(t) AND t.Last_Name='Singh'}


Output:

First_NameLast_NameAge
-----------------------
AjeetSingh30
ChaitanyaSingh31

2. Domain Relational Calculus (DRC)


In domain relational calculus the records are filtered based on the domains.
Again we take the same table to understand how DRC works.
Table: Student

First_NameLast_NameAge
-----------------------
AjeetSingh30
ChaitanyaSingh31

40
RajeevBhatia27
CarlPratap28
Query to find the first name and age of students where student age is greater than 27

{<First_Name,Age>|∈Student∧Age>27}
Note:
The symbols used for logical operators are: ∧ for AND, ∨ for OR and ┓ for NOT.

Output:

First_NameAge
--------------
Ajeet30
Chaitanya31
Carl28

DDL Commands in SQL


DDL is an abbreviation of Data Definition Language.

The DDL Commands in Structured Query Language are used to create and modify the
schema of the database and its objects. The syntax of DDL commands is predefined for
describing the data. The commands of Data Definition Language deal with how the
data should exist in the database.

Following are the five DDL commands in SQL:

1. CREATE Command
2. DROP Command
3. ALTER Command
4. TRUNCATE Command
5. RENAME Command

CREATE Command
CREATE is a DDL command used to create databases, tables, triggers and other
database objects.

Examples of CREATE Command in SQL


Example 1: This example describes how to create a new database using the
CREATE DDL command.
41
Syntax to Create a Database:

1. CREATE Database Database_Name;

Suppose, you want to create a Books database in the SQL database. To do this, you
have to write the following DDL Command:

1. Create Database Books;

Example 2: This example describes how to create a new table using the CREATE
DDL command.

Syntax to create a new table:

1. CREATE TABLE table_name


2. (
3. column_Name1 data_type ( size of the column ) ,
4. column_Name2 data_type ( size of the column) ,
5. column_Name3 data_type ( size of the column) ,
6. ...
7. column_NameN data_type ( size of the column )
8. ) ;

Suppose, you want to create a Student table with five columns in the SQL database. To
do this, you have to write the following DDL command:

1. CREATE TABLE Student


2. (
3. Roll_No. Int ,
4. First_Name Varchar (20) ,
5. Last_Name Varchar (20) ,
6. Age Int ,
7. Marks Int ,
8. ) ;

Example 3: This example describes how to create a new index using the CREATE
DDL command.

Syntax to Create a new index:

1. CREATE INDEX Name_of_Index ON Name_of_Table (column_name_1 , column_n


ame_2 , … . , column_name_N);
42
Let's take the Student table:

Stu_Id Name Marks City State

100 Abhay 80 Noida U.P

101 Sushil 75 Jaipur Rajasthan

102 Ankit 90 Gurgaon Haryana

103 Yogesh 93 Lucknow U.P

Suppose, you want to create an index on the combination of the City and State field of
the Student table. For this, we have to use the following DDL command:

1. CREATE INDEX index_city_State ON Employee (Emp_City, Emp_State);

Example 4: This example describes how to create a trigger in the SQL database
using the DDL CREATE command.

Syntax to create a trigger:

1. CREATE TRIGGER [trigger_name]


2. [ BEFORE | AFTER ]
3. { INSERT | UPDATE | DELETE }
4. ON [table_name] ;

DROP Command
DROP is a DDL command used to delete/remove the database objects from the SQL
database. We can easily remove the entire table, view, or index from the database using
this DDL command.

Examples of DROP Command in SQL


Example 1: This example describes how to remove a database from the SQL
database.

Syntax to remove a database:

1. DROP DATABASE Database_Name;

43
Suppose, you want to delete the Books database from the SQL database. To do this,
you have to write the following DDL command:

1. DROP DATABASE Books;

Example 2: This example describes how to remove the existing table from the SQL
database.

Syntax to remove a table:

1. DROP TABLE Table_Name;

Suppose, you want to delete the Student table from the SQL database. To do this, you
have to write the following DDL command:

1. DROP TABLE Student;

Example 3: This example describes how to remove the existing index from the
SQL database.

Syntax to remove an index:

1. DROP INDEX Index_Name;

Suppose, you want to delete the index_city from the SQL database. To do this, you have
to write the following DDL command:

1. DROP INDEX Index_city;

ALTER Command
ALTER is a DDL command which changes or modifies the existing structure of the
database, and it also changes the schema of database objects.

We can also add and drop constraints of the table using the ALTER command.

Examples of ALTER Command in SQL


Example 1: This example shows how to add a new field to the existing table.

Syntax to add a newfield in the table:

1. ALTER TABLE name_of_table ADD column_name column_definition;

44
Suppose, you want to add the 'Father's_Name' column in the existing Student table. To
do this, you have to write the following DDL command:

1. ALTER TABLE Student ADD Father's_Name Varchar(60);

Example 2: This example describes how to remove the existing column from the
table.

Syntax to remove a column from the table:

1. ALTER TABLE name_of_table DROP Column_Name_1 , column_Name_2 , ….., col


umn_Name_N;

Suppose, you want to remove the Age and Marks column from the existing Student
table. To do this, you have to write the following DDL command:

1. ALTER TABLE StudentDROP Age, Marks;

Example 3: This example describes how to modify the existing column of the
existing table.

Syntax to modify the column of the table:

1. ALTER TABLE table_name MODIFY ( column_name column_datatype(size));

Suppose, you want to change the character size of the Last_Namefield of the Student
table. To do this, you have to write the following DDL command:

1. ALTER TABLE table_name MODIFY ( Last_Name varchar(25));

TRUNCATE Command
TRUNCATE is another DDL command which deletes or removes all the records from the
table.

This command also removes the space allocated for storing the table records.

Syntax of TRUNCATE command

1. TRUNCATE TABLE Table_Name;

Example

45
Suppose, you want to delete the record of the Student table. To do this, you have to
write the following TRUNCATE DDL command:

1. TRUNCATE TABLE Student;

The above query successfully removed all the records from the student table. Let's
verify it by using the following SELECT statement:

1. SELECT * FROM Student;

RENAME Command
RENAME is a DDL command which is used to change the name of the database table.

Syntax of RENAME command

1. RENAME TABLE Old_Table_Name TO New_Table_Name;

Example

1. RENAME TABLE Student TO Student_Details ;

This query changes the name of the table from Student to Student_Details.

DML Commands in SQL


DML is an abbreviation of Data Manipulation Language.

The DML commands in Structured Query Language change the data present in the SQL
database. We can easily access, store, modify, update and delete the existing records
from the database using DML commands.

Following are the four main DML commands in SQL:

1. SELECT Command
2. INSERT Command
46
3. UPDATE Command
4. DELETE Command

SELECT DML Command


SELECT is the most important data manipulation command in Structured Query
Language. The SELECT command shows the records of the specified table. It also shows
the particular record of a particular column by using the WHERE clause.

Syntax of SELECT DML command

1. SELECT column_Name_1, column_Name_2, ….., column_Name_N FROM Name_o


f_table;

Here, column_Name_1, column_Name_2, ….., column_Name_N are the names of


those columns whose data we want to retrieve from the table.

If we want to retrieve the data from all the columns of the table, we have to use the
following SELECT command:

1. SELECT * FROM table_name;

Examples of SELECT Command


Example 1: This example shows all the values of every column from the table.

1. SELECT * FROM Student;

This SQL statement displays the following values of the student table:

Student_ID Student_Name Student_Marks

BCA1001 Abhay 85

BCA1002 Anuj 75

BCA1003 Bheem 60

BCA1004 Ram 79

BCA1005 Sumit 80

Example 2: This example shows all the values of a specific column from the table.

47
1. SELECT Emp_Id, Emp_Salary FROM Employee;

This SELECT statement displays all the values of Emp_Salary and Emp_Id column
of Employee table:

Emp_Id Emp_Salary

201 25000

202 45000

203 30000

204 29000

205 40000

Example 3: This example describes how to use the WHERE clause with the SELECT
DML command.

Let's take the following Student table:

Student_ID Student_Name Student_Marks

BCA1001 Abhay 80

BCA1002 Ankit 75

BCA1003 Bheem 80

BCA1004 Ram 79

BCA1005 Sumit 80

If you want to access all the records of those students whose marks is 80 from the
above table, then you have to write the following DML command in SQL:

1. SELECT * FROM Student WHERE Stu_Marks = 80;

The above SQL query shows the following table in result:

Student_ID Student_Name Student_Marks

48
BCA1001 Abhay 80

BCA1003 Bheem 80

BCA1005 Sumit 80

INSERT DML Command


INSERT is another most important data manipulation command in Structured Query
Language, which allows users to insert data in database tables.

Syntax of INSERT Command

1. INSERT INTO TABLE_NAME ( column_Name1 , column_Name2 , column_Name3


, .... column_NameN ) VALUES (value_1, value_2, value_3, .... value_N ) ;

Examples of INSERT Command


Example 1: This example describes how to insert the record in the database table.

Let's take the following student table, which consists of only 2 records of the student.

Stu_Id Stu_Name Stu_Marks Stu_Age

101 Ramesh 92 20

201 Jatin 83 19

Suppose, you want to insert a new record into the student table. For this, you have to
write the following DML INSERT command:

1. INSERT INTO Student (Stu_id, Stu_Name, Stu_Marks, Stu_Age) VALUES (104, An


mol, 89, 19);

UPDATE DML Command


UPDATE is another most important data manipulation command in Structured Query
Language, which allows users to update or modify the existing data in database tables.

Syntax of UPDATE Command

49
1. UPDATE Table_name SET [column_name1= value_1, ….., column_nameN = value
_N] WHERE CONDITION;

Here, 'UPDATE', 'SET', and 'WHERE' are the SQL keywords, and 'Table_name' is the name
of the table whose values you want to update.

Examples of the UPDATE command


Example 1: This example describes how to update the value of a single field.

Let's take a Product table consisting of the following records:

Product_Id Product_Name Product_Price Product_Quantity

P101 Chips 20 20

P102 Chocolates 60 40

P103 Maggi 75 5

P201 Biscuits 80 20

P203 Namkeen 40 50

Suppose, you want to update the Product_Price of the product whose Product_Id is
P102. To do this, you have to write the following DML UPDATE command:

1. UPDATE Product SET Product_Price = 80 WHERE Product_Id = 'P102' ;

Example 2: This example describes how to update the value of multiple fields of
the database table.

Let's take a Student table consisting of the following records:

Stu_Id Stu_Name Stu_Marks Stu_Age

101 Ramesh 92 20

201 Jatin 83 19

202 Anuj 80 21

203 Monty 95 21

50
102 Saket 65 21

103 Sumit 80 21

104 Ashish 98 20

Suppose, you want to update Stu_Marks and Stu_Age of that student whose Stu_Id is
103 and 202. To do this, you have to write the following DML Update command:

1. UPDATE Student SET Stu_Marks = 80, Stu_Age = 21 WHERE Stu_Id = 103 AND
Stu_Id = 202;

DELETE DML Command


DELETE is a DML command which allows SQL users to remove single or multiple
existing records from the database tables.

This command of Data Manipulation Language does not delete the stored data
permanently from the database. We use the WHERE clause with the DELETE command
to select specific rows from the table.

Syntax of DELETE Command

1. DELETE FROM Table_Name WHERE condition;

Examples of DELETE Command


Example 1: This example describes how to delete a single record from the table.

Let's take a Product table consisting of the following records:

Product_Id Product_Name Product_Price Product_Quantity

P101 Chips 20 20

P102 Chocolates 60 40

P103 Maggi 75 5

P201 Biscuits 80 20

P203 Namkeen 40 50

51
Suppose, you want to delete that product from the Product table whose Product_Id is
P203. To do this, you have to write the following DML DELETE command:

1. DELETE FROM Product WHERE Product_Id = 'P201' ;

Example 2: This example describes how to delete the multiple records or rows
from the database table.

Let's take a Student table consisting of the following records:

Stu_Id Stu_Name Stu_Marks Stu_Age

101 Ramesh 92 20

201 Jatin 83 19

202 Anuj 85 19

203 Monty 95 21

102 Saket 65 21

103 Sumit 78 19

104 Ashish 98 20

Suppose, you want to delete the record of those students whose Marks is greater than
70. To do this, you have to write the following DML Update command:

DELETE FROM Student WHE

52

You might also like