Relational Query Language in DBMS
Last Updated :
06 Oct, 2023
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 -
- Select (sigma): Returns rows of the input relation that satisfy the provided predicate. It is unary Operator means requires only one operand.
- 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.
- 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.
- 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.
- 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:
- 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).
- 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.
Similar Reads
Relational Model in DBMS The Relational Model organizes data using tables (relations) consisting of rows and columns. Each column represents a specific attribute with a unique name, while each row holds data about a real-world entity or relationship. As a record-based model, it stores data in fixed-format records with defin
10 min read
What is Object-Relational Mapping (ORM) in DBMS? Object-relational mapping (ORM) is a key concept in the field of Database Management Systems (DBMS), addressing the bridge between the object-oriented programming approach and relational databases. ORM is critical in data interaction simplification, code optimization, and smooth blending of applicat
7 min read
What is a Query in DBMS? In the field of Database Management Systems (DBMS), a query serves as a fundamental tool for retrieving, manipulating, and managing data stored within a database. Queries act as the bridge between users and databases, enabling them to communicate with the system to extract specific information or pe
5 min read
Relation Schema in DBMS Relation schema defines the design and structure of the relation or table in the database. It is the way of representation of relation states in such a way that every relation database state fulfills the integrity constraints set (Like Primary key, Foreign Key, Not null, Unique constraints) on a rel
6 min read
Creating APIs for Relational Database In the era of software development, relational databases stand as pillars of structured data storage and organization. These databases, with their tables, rows, and columns, provide a reliable framework for managing information. But what makes them truly powerful is their collaboration with APIs, th
8 min read