relational-algebra

Join operators and commutativity

不打扰是莪最后的温柔 提交于 2019-12-02 10:49:45
I am doing some relational algebra exercizes. On a teacher slide I saw a thing that makes me think that there can be an error. I think, the third JOIN, should be JOIN 'Farmacia' as F ON 'D'.'idCF' = 'F'.'idFì instead of JOIN 'Farmacia' as F ON 'F'.'idFì = 'D'.'idCF' Using this last command you will join Farmacia on itself, isn't it? The slide question says: Which pharmacy does sell drug X of phramaceutic company Y? The order of the columns in the ON part of the statement doesn't influence how the JOIN itself is done. This: SELECT t1.columnA, t2.columnB FROM Table1 t1 JOIN Table2 t2 ON t1.ID =

Database Relational Algebra: How to find actors who have played in ALL movies produced by “Universal Studios”?

限于喜欢 提交于 2019-12-02 08:40:37
Given the following relational schemas, where the primary keys are in bold: movie( movieName , whenMade); actor( actorName , age); studio( studioName , location, movieName); actsIn( actorName , movieName ); How do you find the list of actors who have played in EVERY movie produced by "Universal Studios"? My attempt: π actorName ∩ (σ studioName=“Universal Studios” studio) |><| actsIn, where |><| is the natural join Are you supposed to use cartesian product and/or division? :\ Here are the two steps that you should follow: Write an expression to find the names of movies produced by “Universal

relational algebra for Limit Operator

前提是你 提交于 2019-12-01 23:45:50
问题 What is relational algebra for these two SQL queries: Select * from film where film_rating = 'PG' limit 20; How can we show limit? Select * from actor, country where first_name='BOB' and country='In'; where first_name is actor's column and country is country table's column...there is no relationship between these two tables...they are independent tables... so can we use join operator here? 回答1: About the limit in relational algebra. Traditional relational algebra does not support anything

relational algebra for Limit Operator

柔情痞子 提交于 2019-12-01 23:41:06
What is relational algebra for these two SQL queries: Select * from film where film_rating = 'PG' limit 20; How can we show limit? Select * from actor, country where first_name='BOB' and country='In'; where first_name is actor's column and country is country table's column...there is no relationship between these two tables...they are independent tables... so can we use join operator here? About the limit in relational algebra. Traditional relational algebra does not support anything like the limit in SQL. This problem has been recognized and studied by Li, Chang, Ilyas and Song in RankSQL:

How to provide relational algebra for the given schema?

风流意气都作罢 提交于 2019-12-01 15:01:07
EMPLOYEE(PERSONNAME, STREET, CITY) WORKS(PERSONNAME,COMPANYNAME, SALARY) COMPANY(COMPANYNAME, CITY) MANAGES(PERSONNAME, MANAGERNAME) Find the names of all employees in this database who do not work for First Bank Corporation (assuming that all people work for exactly one company and people are allowed to appear in the database (e.g. in employee) but not appear in works). Here I do not understand the assumption part. What does it actually mean ? As @wildplasser pointed out: The first part of the assumption assuming that all people work for exactly one company... declares the case that there is

Can all SQL queries be represented in Relational Algebra, Domain and Tuple relational calculus

旧时模样 提交于 2019-12-01 11:54:21
问题 My query includes a having and count or all in. How are these represented in RA/DRC/TRC? Would I have to simplify my SQL query even more? Here is a simplified example: empl(employee (primary key), city) managers(employee (primary key), manager (foreign key of employee)) If I were to find all the employees who are managers (from any city) of ALL the employees in city X.. I would need to use having/count. Not sure how this would be done in RA/DRC/TRC. I know the need for such a query might not

Can all SQL queries be represented in Relational Algebra, Domain and Tuple relational calculus

帅比萌擦擦* 提交于 2019-12-01 11:49:36
My query includes a having and count or all in. How are these represented in RA/DRC/TRC? Would I have to simplify my SQL query even more? Here is a simplified example: empl(employee (primary key), city) managers(employee (primary key), manager (foreign key of employee)) If I were to find all the employees who are managers (from any city) of ALL the employees in city X.. I would need to use having/count. Not sure how this would be done in RA/DRC/TRC. I know the need for such a query might not make sense but assume it is sensible for the purpose of this question. Thanks Your query was stated a

What is the difference between theta join and inner join?

拈花ヽ惹草 提交于 2019-12-01 10:14:36
问题 theta join and inner join look identical to me: they are Cartesian product followed by an arbitrary selection. Or am I missing their differences? Thanks. The above wikipedia link says a theta-join takes a comparison & two attributes. But that is not correct. Instead, a theta-join can take any selection condition. From Database System Concept which is supposed to follow the SQL standard and more coherent and reliable than wikipedia: The theta join operation is a variant of the natural-join

How to understand `u=r÷s`, the division operator, in relational algebra?

青春壹個敷衍的年華 提交于 2019-12-01 08:27:11
let be a database having the following relational-schemes: R(A,B,D) and S(A,B) with the attributes of same name in the same domain and with the instances r and n . An instance of r An instance of s What is the scheme and what are the tuples of u=r÷s ? How to define them in English with r and s ? My attempt I know that u=r÷s = Which leads me to think that it would only be an array of one column A, but I'm not sure enough to know what will be ther result within the array. Can you help me understand u=r÷s? An intuitive property of the division operator of the relational algebra is simply that it

Difference between Relational Algebra and Relational calculus

孤街醉人 提交于 2019-12-01 04:44:36
What is the exact difference between relational algebra and relational calculus. At most of the reference, it will be Relational algebra is procedural and calculus is non procedural . So, what is these stands for. However, we can solve all the problems using relational algebra. Then why we would use relational calculus. Except definition, Explanation with example is much appreciated. TL;DR: Queries calling RA (relational algebra) operators & queries of the two relational calculi (RCs) TRC (tuple RC) & DRC (domain RC) are different syntax for the same thing: a relation value or the property