relational-algebra

Is there set division in SQL?

送分小仙女□ 提交于 2019-12-20 01:36:05
问题 I'm fully aware that set division can be accomplished through a series of other operations, so my question is: Is there a command for set division in SQL? 回答1: http://vadimtropashko.files.wordpress.com/2007/02/ch3.pdf From Page 32: Relational Division is not a fundamental operator. It can be expressed in terms of projection, Cartesian product, and set difference. So, no. :) 回答2: Related question: Database Design for Tagging And relevant part of answer is this article So in short, no, there is

How to provide relational algebra for the given schema?

夙愿已清 提交于 2019-12-19 12:30:10
问题 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 ? 回答1: As @wildplasser pointed out: The first part

Converting aggregate operators from SQL to relational algebra

五迷三道 提交于 2019-12-18 05:09:07
问题 I have several SQL queries written that I want to convert to relational algebra. However, some of the queries use aggregate operators and I don't know how to convert them. Notably they use COUNT and GROUP BY.. HAVING operators. Here is the schema: Sailors( sid , sname, rating) Reserves( sid , bid , price) Boats( bid , bname) Here is an example of what I'm doing: find the bids and bnames of all boats reserved by exactly 2 sailors. SELECT B.bid, B.bname FROM Boats B, Reserves R WHERE B.bid = R

Difference between one-to-many and many-to-one relationship

大城市里の小女人 提交于 2019-12-17 23:19:20
问题 What is the real difference between one-to-many and many-to-one relationship? It is only reversed, kind of? I can't find any 'good-and-easy-to-understand' tutorial about this topic other than this one: SQL for Beginners: Part 3 - Database Relationships 回答1: Yes, it a vice versa. It depends on which side of the relationship the entity is present on. For example, if one department can employ for several employees then, department to employee is a one to many relationship (1 department employs

Aggregate Relational Algebra (Maximum)

寵の児 提交于 2019-12-17 22:59:29
问题 I am currently working on a homework assignment that requires a selection to occur that pulls out an element containing a specific attribute of maximum value compared to all other records. I've read a number of sources online that reference an "aggregate" relational algebra function called maximum, but they don't describe how it works using the basic operators. How does one select the attribute containing a maximum value? 回答1: You can very well express aggregate functions with only basic

retrieve correct data from my schemas

落爺英雄遲暮 提交于 2019-12-17 16:41:53
问题 I would like to retrieve the Names of teachers who teach more than 1 course I am really stuck on how to do it , all I know is that I need to consider the Course schema and operate on it , could I get some advice in terms of pi(projection),sigma(condition),rho(rename) etc (not i any specific database language)? 回答1: Since this is homework and you basically need to read & work through a textbook's absolutely introductory text & exercises on relational model basics & the relational algebra, I

What are projection and selection?

巧了我就是萌 提交于 2019-12-17 07:10:14
问题 What is the difference between projection and selection? Is it: Projection --> for selecting the columns of table; and Selection ---> to select the rows of table? So are projection and selection vertical and horizontal slicing respectively? 回答1: Exactly. Projection means choosing which columns (or expressions) the query shall return. Selection means which rows are to be returned. if the query is select a, b, c from foobar where x=3; then "a, b, c" is the projection part, "where x=3" the

relational algebra of the query

只谈情不闲聊 提交于 2019-12-14 00:08:37
问题 Consider the following relational database schemes: COURSES (Cno,name) PRE-REQ(Cno, pre-Cno) COMPLETED (student_no, Cno) COURSES gives the number and name of all the available courses. PRE-REQ gives the information about which courses are pre-requisites for a given course. COMPLETED indicates what courses have been completed by students Express the following using relational algebra: List all the courses for which a student with student_no = 2310 has completed all the pre-requisites. the

Must a natural join be on a shared primary key?

戏子无情 提交于 2019-12-13 09:47:14
问题 Suppose I perform A natural join B, where: A's schema is: (aID), where (aID) is a primary key. B's schema is: (aID,bID), where (aID, bID) is a composite primary key. Would performing the natural join work in this case? Or is it necessary for A to have both aID and bID for this to work? 回答1: NATURAL JOIN returns rows with one copy each of the common input table column names and one copy each of the column names that are unique to an input table. It returns a table with all such rows that can

Relational Join and Operators in Alloy

和自甴很熟 提交于 2019-12-13 07:19:15
问题 I've been going over Alloy in general and found some concepts that I need some clearance on. First of all, the . (Dot Join). I got how it works for trivial examples but in a case like this: sig B {} sig A { rel: B -> C } sig C { rel1: B -> A } rel = {(a1,b1,c1), (a2,b2,c2)} rel1 = {(c1,b1,a1),(c2,b2,a2)} rel.rel1 = {(a1,b1,b1,a1),(a2,b2,b2,a2)} rel1.rel = {(c1,b1,b1,c1),(c2,b2,b2,c2) I don't get the result of rel.rel1 or rel1.rel. Can somebody explain how it works please? I am also having