relational-algebra

Can I Join 3 table using Natural Join?

孤者浪人 提交于 2019-12-13 00:53:02
问题 The image down below shows a small database, I got a question Give a relational algebra expression to find the name of the judge who presides over the trial for defendant known as “Mike” starting on 1.12.2012. And the answer given is But I think it should Join JUDGE table as well something like this : Please leave some comment if I' wrong about this 回答1: Nope, you don't need to join the JUDGE table to get the judge's name. Notice how Jname is the primary key of JUDGE s, that is to say, a

How to compute a natural join?

若如初见. 提交于 2019-12-12 09:58:46
问题 Could someone explain to me what is going on here and how to solve this problem? Suppose relation R(A,B) has the tuples: A B 1 2 3 4 5 6 and the relation S(B,C,D) has tuples: B C D 2 4 6 4 6 8 4 7 9 Compute the natural join of R and S. Then, identify which of the following tuples is in the natural join R |><| S. You may assume each tuple has schema (A,B,C,D). I don't know what a natural join truly means. Can you explain it to me? 回答1: A natural join is joining ("sticking together") elements

Natural join if no common attributes

匆匆过客 提交于 2019-12-12 08:22:43
问题 What will natural join return in relational algebra if tables don't have attributes with same names? Will it be null or the same as cross-product (Cartesian operator)? 回答1: If there are no attributes in common between two relations and you perform a natural join , it will return the cartesian product of the two relations. 回答2: A cartesian product of two tables will be returned.This is because when we perform any JOIN operation on two tables a cartesian product of those tables is performed and

Theta Join in Relational Algebra Correctness

╄→гoц情女王★ 提交于 2019-12-12 05:32:58
问题 Considering these two tables: Band (band_id, band_name) Band_Member (band_id, member_name, dob, country, sex) The task: List the names of band members and the names of the bands they are in using the theta Join. Well, my doubt is in the step to show only the band_name and member_name after the join. This is how I've done the theta-join: σ Band_Member.band_id = Band.band_id (Band_member x Band) And this is how I think it might be correct to show only the band_name and member_name: Π band_name,

DATE in sql and relation Algebra is NULL?

别等时光非礼了梦想. 提交于 2019-12-11 20:35:17
问题 I have a questions is it possible to set a date in tables NULL(in my case that a shipdate does not exist)? E.g I have this following tables: Customer{cid,name} Product{prodno,name} Order{orderid, shipdate, cid} Ordered{orderid, prodno, quantity} And now I wanto to get all Products which were never ordered. So I create this in RA(Relational Algebra): πP.name,P.prodno(σO.cid = C.cid AND Order.shipdate is NULL(Order)))⋈Customer) I am sure that it looks in SQL query: SELECT P.Name, P.Prodno FROM

What does the multiply operator do relational algebra?

こ雲淡風輕ζ 提交于 2019-12-11 13:12:13
问题 I'm new to relational algebra. I found the * operator in the following expression What's the different this and one using join 回答1: The * should more correctly be written × as it represents a Cartesian product. This operation returns the set of all tuples that are the concatenation of tuples from each operand. A join filters the Cartesian product down to only those tuples with matching values on specified attributes. If the join is a natural join, as in your example, the attributes matched on

Selecting from three Relation with Relational Algebra

断了今生、忘了曾经 提交于 2019-12-11 09:42:43
问题 I have for ex this Tables Customer{cid, name, phone, address} Employee{eid, name, positon, salary} Resp_for{cid,eid} Now I want to ask in relational Algebra that it should print out all employees that are resposible for the Customer: 'Obama' I am trying it but not sure that I understand the relational algebra clearly, so I create this: PROJECT (SELECT (Customer x Employeee x Resp_for)) E.eid C.name = 'Obama' AND R.cid = C.cid And R.eid = E.eid so how it looks as sql query? SELECT E.eid FROM

Converting Relational Algebra to corresponding SQL Query

天大地大妈咪最大 提交于 2019-12-11 08:08:04
问题 I am trying to understand how to convert properly from Relational Algebra into SQL queries I find this is one of the things I struggle to convert between. Would anyone be able to share any tips? Tables: Room(_roomId_, numberOfBeds, price) Guest(_guestId_, homeTown, age) Reservation(_roomId_, _guestId_, date) Relational Algebra: Πprice(ΠroomId(ΠguestId(σage<20)Guest) Natural Join Reservation) Natural Join Room Query: I managed to deduce the following from part of the statement: SELECT roomId

Which of the following can you NOT do in relational algebra?

拜拜、爱过 提交于 2019-12-11 05:08:18
问题 tldr; Which of the three below can you not write in RA? Our prof asked us to write 3 SQL queries. He then asked us which of them could not be written in Relation Algebra. They are as follows: Given the following 3 tables: Students (sID, sName); (Primary Key sID) Courses (cID, cName); (Primary Key cID) Enrolled (sID, cID, sectID, grade) (Primary Key sID, cID) where foreign key (sID) references Students, foreign key (cID) references Courses. Find the largest student ID. Get a class list

Relational Algebra and Confusing one Complex Examples

笑着哭i 提交于 2019-12-11 03:38:30
问题 We have 3-Relation: Students(sid, sname) Courses(cid, cname, dept) take(sid, cid, grade) We want to find student numbers of students whose these students take all courses that present in 'CS' department . why (line 4) is the answer of this query ? anyone could say differ from (line 1) to (line 3). I read this in Solved-Ex in DB. 回答1: Another way to phrase the fourth line is: all students except ( all combinations of students and CS courses except all taken courses ) The set between brackets