relational-algebra

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

ⅰ亾dé卋堺 提交于 2019-12-01 04:13:04
问题 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

Represent a subquery in relational algebra

蹲街弑〆低调 提交于 2019-11-30 15:31:33
问题 How do I represent a subquery in relation algebra? Do I put the new select under the previous select condition? SELECT number FROM collection WHERE number = (SELECT anotherNumber FROM anotherStack); 回答1: You would just rewrite that as a join . I'm not sure how widely used the syntax I learned for Relational Algebra is so in words. Take a projection of anotherNumber from anotherStack Rename anotherNumber from the result of step 1 as number Natural Join the result of step 2 onto collection Take

Represent a subquery in relational algebra

巧了我就是萌 提交于 2019-11-30 14:41:40
How do I represent a subquery in relation algebra? Do I put the new select under the previous select condition? SELECT number FROM collection WHERE number = (SELECT anotherNumber FROM anotherStack); You would just rewrite that as a join . I'm not sure how widely used the syntax I learned for Relational Algebra is so in words. Take a projection of anotherNumber from anotherStack Rename anotherNumber from the result of step 1 as number Natural Join the result of step 2 onto collection Take a final projection of number from the result of step 3 The answer depends on which operators your algebra

Is multiplication allowed in relational algebra?

戏子无情 提交于 2019-11-30 10:01:33
问题 I have a relation R ------- cid sid gradepoint credits CS425 001 4.0 3 I need to calculate the GPA. There are more rows, but I believe if I just get this answered I should be ok with the rest. I need to do gradepoint * credits . How do I express this with a relational algebra expression? My best guess is: , but I'm not sure if I can multiply attributes with anything other than a constant. 回答1: Relational algebra doesn't address domain-specific operations. It neither includes nor excludes it,

What is the difference between Select and Project Operations

﹥>﹥吖頭↗ 提交于 2019-11-29 22:48:41
I'm referring to the basic relational algebra operators here. As I see it, everything that can be done with project can be done with select. I don't know if there is a difference or a certain nuance that I've missed. Select Operation : This operation is used to select rows from a table (relation) that specifies a given logic, which is called as a predicate . The predicate is a user defined condition to select rows of user's choice. Project Operation : If the user is interested in selecting the values of a few attributes, rather than selection all attributes of the Table (Relation), then one

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

假如想象 提交于 2019-11-29 18:55:59
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 Devendra D. Chavan 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 many employees), while employee to department relationship is many to one (many employees

Is multiplication allowed in relational algebra?

那年仲夏 提交于 2019-11-29 18:16:30
I have a relation R ------- cid sid gradepoint credits CS425 001 4.0 3 I need to calculate the GPA. There are more rows, but I believe if I just get this answered I should be ok with the rest. I need to do gradepoint * credits . How do I express this with a relational algebra expression? My best guess is: , but I'm not sure if I can multiply attributes with anything other than a constant. Relational algebra doesn't address domain-specific operations. It neither includes nor excludes it, just like real algebra neither includes nor excludes operations on relations. If you allow multiplication by

Expressing “is null” in Relational algebra

喜夏-厌秋 提交于 2019-11-29 16:30:20
In SQL, if I want to know whether an expression is NULL, I can use is null . But I don't understand how I can express is null in relational algebra. Can I use δ Field_Name=NULL(Table_Name) ? There is no NULL in relational algebra. In SQL the operators treat the value NULL specially, syntactically and semantically, differently than other values, usually by returning NULL when comparing two values when one of them is NULL. So "=" in a WHERE is not equality, it is an operator like equality that acts differently for NULL. So SQL WHERE is not the same operator as algebraic RESTRICT. If someone

Converting aggregate operators from SQL to relational algebra

你。 提交于 2019-11-29 07:59:37
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.bid GROUP BY R.bid HAVING 2 = (SELECT COUNT(*) FROM Reserves R2 WHERE R2.bid = B.bid); Allowable

What is the difference between Select and Project Operations

半城伤御伤魂 提交于 2019-11-28 18:51:44
问题 I'm referring to the basic relational algebra operators here. As I see it, everything that can be done with project can be done with select. I don't know if there is a difference or a certain nuance that I've missed. 回答1: Select Operation : This operation is used to select rows from a table (relation) that specifies a given logic, which is called as a predicate . The predicate is a user defined condition to select rows of user's choice. Project Operation : If the user is interested in