 Hello friends, today we will see formal relational query languages. There are three formal languages, relational algebra which forms the basis of SQL whereas tuple relational calculus and domain relational calculus based on mathematical languages are the declarative language. So, today we will see relational algebra. So, learning outcome for the session is at the end of this session students will be able to write relational algebra expression using select, project and rename operations as well as they will be able to write equivalent relational algebra expression for given SQL statement. So, relational algebra is a procedural query language it has a set of operations which can which takes one or two relations as an input and produces a new relation. The fundamental operations are select, project, rename, union, set difference and Cartesian product. Select, project and rename are the unary operation means it takes one relation as an input whereas union, set difference and Cartesian product are the binary operations which take two relations as input. The other operations are set intersection, natural join, assignment and so on. So, first we will see the select operation. The notation for this is that select with predicate p from the relation r. So, select tuples will satisfy it select operation selects a tuples will satisfy a given predicate. Now, selection operation is denoted by the lowercase Greek letter sigma p is a predicate or a condition for selection. So, it is a logical formula obtained using the comparison operators like equal to not equal to less than greater than so on and the connectives and or not. r is a relation on which selection operation is performed. So, when we want from specific tuples we can use selection operation in relational algebra. Now, consider this example it is a student relation from where there are four attributes department id, class id, roll number and name. So, first example that select predicate is class id equal to t from the relation student. Now, the class id equal to t. So, if we will go through the relation there are four records or the tuples having this class id equal to t. So, new relation that we will get is having four tuples from this particular algebra expression. Now, consider the second example select class id equal to s e or class id equal to t from student. So, at this moment pause the video and try to find out the output relation. So, we have already found the relations or the we have already found the records with class id equal to s e and then we are finding with t. So, these are the records which are having the class id either s e or t. So, that we have got as a new relation. So, equivalence of this select operation in SQL is same as where clause. So, select operation is equivalent to where clause in SQL. So, whatever the predicate that we are giving here is a where clause this is the relation name and the select operator. So, what will be the equivalent SQL statement? So, select this from this relation where this condition. So, select start from is nothing, but equivalent to this particular symbol sigma from student relation where class id equal to t. This is a equivalent SQL statement. So, we have seen select operation. The next operation is project operation. So, sometimes we do not want all the attributes in the operation. We want few attributes in the operation or in the process. So, project is operation which returns relation with selected attributes. So, project is denoted by the Greek letter pi a 1 a 2 dash dash a n are the attributes that we are interested in and r is a relation. So, consider again the same relation student. Now, department id we want to project only the department id. So, how we will write it? Project the name of the attribute that we are interested in and the name of the relation. So, what will be the output? Now, here this is a particular column which we are projecting or which we are selecting. So, how many records are there are multiple records, but if we look at the result it is containing only the single record because relational algebra gives the relation as a set. So, we do not have any duplicates. So, project operation removes duplicates. So, though there are multiple records having this value as an id we are getting only the single record here. Now, consider the second example project department id class id from student ok. So, again pause video and try to write down the output relation. So, here we want to project department id and class id or we want to select two attributes department id and class id. So, what will be the output? Again same here there are three records of it and se class, but we are getting only a single record in the same manner it department and t class id and id department we. So, we are getting three records in the relation. Now, equivalence of this operation again to the skill statement. So, project operation is same as select clause in SQL. So, what will be the SQL statement here? So, try to write down the SQL statement for this given relation for this relational algebra expression. So, select department id class id the attributes that we are projecting from student. So, this is a equivalent relation or if you are having select department id class id from student the equivalent expression will be instead of select we will be having this letter pi then the name of the attributes and the name of the relation this is the project operation. Now, consider we want to find roll number and name of student of se class from id department. So, here first you write down the SQL statement for this particular task. So, what we want roll number and name these are the attributes of students means we are having the student relation of se class from id department. So, what is the condition class is se and department is id. So, as we have discussed in the previous. So, select roll number and name. So, select roll number and name from student where class id is equal to se and department id is equal to id. Now, equivalent is relational algebra expression select. So, which is nothing but project roll number comma name and the condition is going to be select class id equal to se and department id equal to it from this relation student. So, we have a combined project and select operation. So, how it will be executed the first step is that inside statement. So, we are selecting the tuples where class id is equal to se and department id is equal to it. So, these three records are selected. What is the second step projecting the roll number and name. So, here we are projecting only the roll number and name. So, this is what the output relation of this particular query. So, we can combine a number of operations in this relational algebra. The sequence of operation that we will say it in the next lecture that what are the properties whether they are associative commutative and so on. The next operation is a rename operation. Now, we have seen in the previous example also that this is a result, but in relational algebra the result new relation that we have obtained does not have any name. So, if we want to use this further in the next operation we have to rename this relation. So, we can use this rename operation. So, notation is again this is denoted by the Greek writer rho, x is going to be the name that we are using for the result and e is the relational algebra expression. We can also use we can also rename the relation with the rename operator if we want to use same relation twice or thrice in the process. Second form of the rename operation is this at rho, x and we are having the attribute. So, along with the relation name we can also rename attributes. So, result of expression is saved with name x and the attributes with this result. So, consider this student relation. Now, consider this particular expression. Select class id equal to se and department id equal to it from student and rename the relation with seit. We have already executed this particular query and we have got this relation. Only instead of saying now this is a new relation we are renaming it with seit. So, further if we want to use these tuples in one of the form we can use this seit name. Okay. So, pause the video at this moment and try to find out an expression for the task that create new relation seit by renaming the attributes to dvpt that is department, class, roll number, name containing only seit student records from the student relation. So, whenever you have given a task try to find out the operations that we want to use. So, we want to create a new relation with this name means we want rename operation. We want to rename these attributes also. From student relations the name of the relation is student and what are the records seit student records. So, what is the condition the class is se and department is it. So, try to write down the relation or the SQL statement or the relational algebra expression. So, again we have already seen this form only what we want to rename as the attribute. So, we have renamed the attributes with seit as the name of relation, department, class, roll number and name. So, again the output is same only we have renamed this attributes with this nomenclature or the names that we have specified. So, rename is an operation which we will see in the further lectures also at the time of Cartesian product. So, today we have seen three operations in the relational algebra select, project and rename which are unary operations. In the next lecture we will see binary operations. Thank you.