How Queries can be Categorized in Relational Database?

The queries to deal with relational database can be categorized as:

  • Data Definition Language:It is used to define the structure of the database. e.g; CREATE TABLE, ADD COLUMN, DROP COLUMN and so on.
  • Data Manipulation Language:It is used to manipulate data in the relations. e.g.; INSERT, DELETE, UPDATE and so on.
  • Data Query Language:It is used to extract the data from the relations. e.g.; SELECT So first we will consider the Data Query Language. A generic query to retrieve data from a relational database is:
  1. SELECT [DISTINCT] Attribute_List FROM R1,R2….RM
  2. [WHERE condition]
  3. [GROUP BY (Attributes)[HAVING condition]]
  4. [ORDER BY(Attributes)[DESC]];

Part of the query represented by statement 1 is compulsory if you want to retrieve from a relational database. The statements written inside [] are optional. We will look at the possible query combination on relation shown in Table 1.

Structured Query Language (SQL)

Structured Query Language is a standard Database language that is used to create, maintain, and retrieve the relational database. In this article, we will discuss this in detail about SQL. Following are some interesting facts about SQL. Let’s focus on that.

SQL is case insensitive. But it is a recommended practice to use keywords (like SELECT, UPDATE, CREATE, etc.) in capital letters and use user-defined things (like table name, column name, etc.) in small letters.

We can write comments in SQL using “–” (double hyphen) at the beginning of any line. SQL is the programming language for relational databases (explained below) like MySQL, Oracle, Sybase, SQL Server, Postgre, etc. Other non-relational databases (also called NoSQL) databases like MongoDB, DynamoDB, etc. do not use SQL.

Although there is an ISO standard for SQL, most of the implementations slightly vary in syntax. So we may encounter queries that work in SQL Server but do not work in MySQL.

Similar Reads

What is Relational Database?

A relational database means the data is stored as well as retrieved in the form of relations (tables). Table 1 shows the relational database with only one relation called STUDENT which stores ROLL_NO, NAME, ADDRESS, PHONE, and AGE of students....

Important Terminologies

These are some important terminologies that are used in terms of relation....

How Queries can be Categorized in Relational Database?

The queries to deal with relational database can be categorized as:...

Different Query Combinations

Case 1: If we want to retrieve attributes ROLL_NO and NAMEof all students, the query will be:...

Aggregation Functions

Aggregation functions are used to perform mathematical operations on data values of a relation. Some of the common aggregation functions used in SQL are:...

Conclusion

SQL is a standard language used to manage data in relational databases. SQL is mainly divided into four main categories: Data definition language, data manipulation language, transaction control language, and data query language and SQL is a powerful language that can be used to carry out a wide range of operations like insert ,delete and update....