Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Notes  >  PPT - Relational Algebra and Relational Calculus

PPT - Relational Algebra and Relational Calculus - Computer Science Engineering (CSE) PDF Download

Download, print and study this document offline
Please wait while the PDF view is loading
 Page 1


1
Relational Algebra & Calculus
Page 2


1
Relational Algebra & Calculus
2
Relational Query Languages
v Query languages: Allow manipulation and retrieval
of data from a database.
v Relational model supports simple, powerful QLs:
§ Strong formal foundation based on logic.
§ Allows for much optimization.
v Query Languages != programming languages!
§ QLs not expected to be “Turing complete”.
§ QLs not intended to be used for complex calculations.
§ QLs support easy, efficient access to large data sets.
Page 3


1
Relational Algebra & Calculus
2
Relational Query Languages
v Query languages: Allow manipulation and retrieval
of data from a database.
v Relational model supports simple, powerful QLs:
§ Strong formal foundation based on logic.
§ Allows for much optimization.
v Query Languages != programming languages!
§ QLs not expected to be “Turing complete”.
§ QLs not intended to be used for complex calculations.
§ QLs support easy, efficient access to large data sets.
3
Formal Relational Query Languages
v Two mathematical Query Languages form the
basis for “real” languages (e.g. SQL), and for
implementation:
§ Relational Algebra: More operational (procedural), very
useful for representing execution plans.
§ Relational Calculus: Lets users describe what they
want, rather than how to compute it: Non-operational,
declarative.
Page 4


1
Relational Algebra & Calculus
2
Relational Query Languages
v Query languages: Allow manipulation and retrieval
of data from a database.
v Relational model supports simple, powerful QLs:
§ Strong formal foundation based on logic.
§ Allows for much optimization.
v Query Languages != programming languages!
§ QLs not expected to be “Turing complete”.
§ QLs not intended to be used for complex calculations.
§ QLs support easy, efficient access to large data sets.
3
Formal Relational Query Languages
v Two mathematical Query Languages form the
basis for “real” languages (e.g. SQL), and for
implementation:
§ Relational Algebra: More operational (procedural), very
useful for representing execution plans.
§ Relational Calculus: Lets users describe what they
want, rather than how to compute it: Non-operational,
declarative.
4
Preliminaries
v A query is applied to relation instances, and the
result of a query is also a relation instance.
§ Schemas of input relations for a query are fixed.
§ The schema for the result of a given query is also
fixed! - determined by definition of query language
constructs.
v Positional vs. named-field notation:
§ Positional notation easier for formal definitions,
named-field notation more readable.
§ Both used in SQL
Page 5


1
Relational Algebra & Calculus
2
Relational Query Languages
v Query languages: Allow manipulation and retrieval
of data from a database.
v Relational model supports simple, powerful QLs:
§ Strong formal foundation based on logic.
§ Allows for much optimization.
v Query Languages != programming languages!
§ QLs not expected to be “Turing complete”.
§ QLs not intended to be used for complex calculations.
§ QLs support easy, efficient access to large data sets.
3
Formal Relational Query Languages
v Two mathematical Query Languages form the
basis for “real” languages (e.g. SQL), and for
implementation:
§ Relational Algebra: More operational (procedural), very
useful for representing execution plans.
§ Relational Calculus: Lets users describe what they
want, rather than how to compute it: Non-operational,
declarative.
4
Preliminaries
v A query is applied to relation instances, and the
result of a query is also a relation instance.
§ Schemas of input relations for a query are fixed.
§ The schema for the result of a given query is also
fixed! - determined by definition of query language
constructs.
v Positional vs. named-field notation:
§ Positional notation easier for formal definitions,
named-field notation more readable.
§ Both used in SQL
5
Example Instances
sid sname rating age
22 dustin 7 45.0
31 lubber 8 55.5
58 rusty 10 35.0
sid sname rating age
28 yuppy 9 35.0
31 lubber 8 55.5
44 guppy 5 35.0
58 rusty 10 35.0
sid bid day
22 101 10/10/96
58 103 11/12/96
R1
S1
S2
v “Sailors” and “Reserves”
relations for our examples.
v We’ll use positional or
named field notation,
assume that names of fields
in query results are
`inherited’ from names of
fields in query input
relations.
Read More

FAQs on PPT - Relational Algebra and Relational Calculus - Computer Science Engineering (CSE)

1. What is relational algebra and how is it related to relational calculus?
Relational algebra is a procedural query language used to perform operations on relations (tables) in a relational database. It consists of a set of operations such as selection, projection, union, intersection, and join, which can be used to retrieve and manipulate data. On the other hand, relational calculus is a non-procedural query language that specifies what data to retrieve from a database without specifying how to retrieve it. It uses logical formulas and quantifiers to define conditions for selecting data. Both relational algebra and relational calculus are related as they provide different ways to express and manipulate data in a relational database.
2. What are the main operations in relational algebra?
The main operations in relational algebra are: - Selection: It retrieves tuples (rows) from a relation (table) that satisfy a given condition. - Projection: It retrieves specific attributes (columns) from a relation while discarding the rest. - Union: It combines two relations and removes any duplicate tuples. - Intersection: It retrieves tuples that are common to two relations. - Difference: It retrieves tuples that are present in one relation but not in another. - Cartesian Product: It combines all tuples from one relation with all tuples from another relation. - Join: It retrieves tuples from two relations based on a common attribute.
3. How does relational algebra help in database management systems?
Relational algebra plays a crucial role in database management systems (DBMS) by providing a formal framework to manipulate and retrieve data from a relational database. It helps in the following ways: - Querying Data: Relational algebra allows users to write queries to retrieve specific data from a database using various operations like selection, projection, and join. - Data Manipulation: It provides operations to modify and update data in a database, such as inserting, deleting, and updating tuples. - Data Integrity: Relational algebra helps enforce data integrity constraints in a database by specifying conditions that data must satisfy. - Query Optimization: DBMS can use relational algebra to optimize query execution by rearranging operations and selecting efficient algorithms. - Database Design: Relational algebra aids in the design and normalization of a database schema by providing a formal and mathematical foundation.
4. What is the difference between relational algebra and SQL?
The main differences between relational algebra and SQL (Structured Query Language) are as follows: - Procedural vs. Declarative: Relational algebra is a procedural query language, where users specify the sequence of operations to retrieve or manipulate data. SQL, on the other hand, is a declarative query language, where users specify what data they want to retrieve or manipulate, and the database management system determines how to execute the query. - Formality: Relational algebra is a formal, mathematical framework with well-defined operations and rules. SQL is a more flexible and natural language, but it lacks the formal rigor of relational algebra. - Expressiveness: Relational algebra has a limited set of operations, whereas SQL provides a wide range of operations and features, including aggregation, sorting, grouping, and complex joins. - Implementation: Relational algebra is used as a theoretical foundation for database systems, whereas SQL is the standard language used to interact with relational databases. - Portability: SQL is widely adopted and supported by various database systems, making it more portable across different platforms and vendors.
5. How is relational algebra used in database optimization?
Relational algebra plays a crucial role in database optimization by helping the database management system (DBMS) to optimize query execution. Here's how it is used: - Query Rewriting: The DBMS translates SQL queries into an equivalent relational algebra expression, which is then optimized. Relational algebra provides a formal representation that can be rearranged and transformed to improve query performance. - Operator Selection: Relational algebra helps in selecting the most efficient physical operators to execute a query, such as choosing the appropriate join algorithm or index access method. - Query Optimization Techniques: Various optimization techniques, such as join reordering, predicate pushdown, and common subexpression elimination, are based on relational algebra principles. These techniques aim to minimize the overall cost of executing a query. - Cost Estimation: Relational algebra provides a basis for estimating the cost of different query execution plans. The DBMS can analyze the size and selectivity of relations, cardinality estimation, and other factors to estimate the cost of executing a query and choose the optimal plan. Overall, relational algebra enables the DBMS to optimize query execution by leveraging formal rules and optimization techniques.
Download as PDF

Top Courses for Computer Science Engineering (CSE)

Related Searches

MCQs

,

Important questions

,

Objective type Questions

,

pdf

,

Sample Paper

,

Semester Notes

,

Free

,

PPT - Relational Algebra and Relational Calculus - Computer Science Engineering (CSE)

,

Extra Questions

,

Previous Year Questions with Solutions

,

Summary

,

past year papers

,

study material

,

PPT - Relational Algebra and Relational Calculus - Computer Science Engineering (CSE)

,

mock tests for examination

,

Exam

,

shortcuts and tricks

,

PPT - Relational Algebra and Relational Calculus - Computer Science Engineering (CSE)

,

video lectures

,

ppt

,

practice quizzes

,

Viva Questions

;