Open In App

Relational Query Language in DBMS

Last Updated : 06 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

SQL has its own querying methods to interact with the database. But how do these queries work in the database? These queries work similarly to Relational Algebra that we study in mathematics. In the database, we have tables participating in relational Algebra.

Relational Database systems are expected to be equipped with a query language that assists users to query the database. Relational Query Language is used by the user to communicate with the database user requests for the information from the database. Relational algebra breaks the user requests and instructs the DBMS to execute the requests. It is the language by which the user communicates with the database. They are generally on a higher level than any other programming language. These relational query languages can be Procedural and Non-Procedural.

Types of Relational Query Language

There are two types of relational query language:

  • Procedural Query Language
  • Non-Procedural Language

Procedural Query Language

In Procedural Language, the user instructs the system to perform a series of operations on the database to produce the desired results. Users tell what data to be retrieved from the database and how to retrieve it. Procedural Query Language performs a set of queries instructing the DBMS to perform various transactions in sequence to meet user requests.

Relational Algebra is a Procedural Query Language

Relational Algebra could be defined as the set of operations on relations.

There are a few operators that are used in relational algebra –

  1. Select (sigma): Returns rows of the input relation that satisfy the provided predicate. It is unary Operator means requires only one operand.
  2. Projection (ℼ): Show the list of those attribute which we desire to appear and rest other attributes are eliminated from the table. It seperates the table vertically.
  3. Set Difference (-): It returns the difference between two relations . If we have two relations R and S them R-S will return all the tuples (row) which are in relation R but not in Relation S , It is binary operator.
  4. Cartesian Product (X): Combines every tuple (row) of one table with every tuple (row) in other table ,also referred as cross Product . It is a binary operator.
  5. Union (U): Outputs the union of tuples from both the relations. Duplicate tuples are eliminated automatically. It is a binary operator means it require two operands.

Non-Procedural Language

In Non Procedural Language user outlines the desired information without giving a specific procedure or without telling the steps by step process for attaining the information. It only gives a single Query on one or more tables to get .The user tells what is to be retrieved from the database but does not tell how to accomplish it.

For Example: get the name and the contact number of the student with a Particular ID will have a single query on STUDENT table.

Relational Calculus is a Non Procedural Language .

Relational Calculus exists in two forms:

  1. Tuple Relational Calculus (TRC): Tuple Relational Calculus is a non procedural query language , It is used for selecting the tuples that satisfy the given condition or predicate . The result of the relation can have one or more tuples (row).
  2. Domain Relational Calculus (DRC): Domain Relational Calculus is a Non Procedural Query Language , the records are filtered based on the domains , DRC uses the list of attributes to be selected from relational based on the condition.

FAQ’s on Relational Query Language

Q.1: What is the difference between Relational Calculus and Relational Algebra ?

Answer:

Relational Algebra is a Procedural Query Language whereas Relational Calculus is a Non Procedural Query Language.
Relational Algebra targets on how to get the result whereas Relational Calculus focuses on what result is to be obtained.

Q.2: What is Relational Algebra?

Answer:

Relational Algebra is a Procedural Query Language that targets on how to get the results , It take instances of relations as input and then yields instances of relations as output ,it is performed recursively on a relation.

Q.3: What is the use of Relational Query Language?

Answer:

Relational Query Language is used by users to communicate with the database , It uses relational Algebra to break the user requests and instructs the DBMS to execute those requests . Relational Query Language can be Procedural or Non Procedural.

Q.4: What are the types of Relational Calculus?

Answer:

There are two types of Relational Calculus Tuple Relational Calculus and Domain Relational Calculus.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads