Ticker

6/recent/ticker-posts

Relational algebra and Relational Calculus

 

   Relational algebra:---


Relational algebra is a procedural query language. It gives a step by step process to obtain the result of the query. It uses operators to perform queries.

    Types:--

1.select operation:--
Select tuples that satisfied the given condition.
select operation is simply denoted by sigma (σ).
       Notation:  σ p(r)  

σ is used for selection prediction
r is used for relation
p is used as a propositional logic formula which may use connectors like: AND OR and NOT. These relational can use as relational operators like =, ≠, ≥, <, >, ≤.


project operation:---

shows list of attributes ,the user wants. As it is denoted by:--∏.
Notation: ∏ A1, A2, An (r)   

A1, A2, A3 is used as an attribute name of relation r.

Union operation:-- select the attributes of the given two relations .But it eliminates the duplicate one.

This operation is denoted by:--U..


Set Intersection:  Let's there are two tuples A and B. The set intersection operation contains all tuples that are in both A & B.
It is denoted by intersection ∩.


Set Difference:

Let's there are two tuples A and B. The set intersection operation contains all tuples that are in A but not in B.
It is denoted by intersection minus (-).


Cartesian product:---The Cartesian product is used to combine each row of a table with each row in the other table. It is also known as a cross product.
It is denoted by X.


Rename Operation::---The rename operation is used to rename the output relation. It is denoted by rho (ρ).



    Join Operations:


A Join operation combines related tuples from different relations(tables), if the  given join condition is satisfied. It is denoted by ⋈.

types:---


 Natural Join::---A natural join is the set of tuples of all combinations in A and B that are equal on their common attribute names.
It is denoted by ⋈.


Outer Join:
The outer join operation is an extension of the join operation. It is used to deal with missing information.

An outer join is basically of three types:




Left outer join:--In the left outer join, tuples in A have no matching tuples in B.
It is denoted by ⟕.


Right outer join:---In right outer join, tuples in B have no matching tuples in A. 
It is denoted by ⟖.


Full outer join:--In full outer join, tuples in A that have no matching tuples in B and tuples in B that have no matching tuples in A in their common attribute name.
It is denoted by ⟗.




Equi join:
    Equi join  based on equality condition. The equi join uses the comparison operator(=).  Data items are matched using equal operator. Equi operator also known as inner join


.
Relational Calculus:---

Relational calculus is a non-procedural query language. Simply tells us what to do but never explains how to do.


Types of Relational calculus:   


     Tuple Relational Calculus (TRC):----


The tuple relational calculus is specified to select the tuples in a relation based on particular condition.The result
 of the relation can have one or more tuples. In TRC, filtering variable uses the tuples of a relation. In TRC, we can use Existential (∃) and Universal Quantifiers (∀).





Domain Relational Calculus (DRC):---In domain relational calculus, filtering variable uses the domain of attributes. It uses logical connectives ∧ (and), ∨ (or) and ┓ (not).
It uses Existential (∃) and Universal Quantifiers (∀) to bind the variable.



Instances and schemas:---


 The collection of information stored in database at a particular moment is known as instance of the database 
And the schema of the database is defined as the overall design of the database .A database schema corresponds to the programming language type definition . Database schema
have several schemas .The schema at the lowest level is known as physical schema and at the intermediator level is known as logical schema and at the highest level is subschema 



Post a Comment

0 Comments