relational-algebra

Relational algebra - recode column values

泄露秘密 提交于 2019-11-28 01:45:18
Suppose I have a table 'animals' whose rows represent different animals and there is a column species that might have values like 'cat', 'dog', 'horse', 'cow' etc. Suppose I am only interested in whether the animal is a dog or not. In sql (at least in MySQL) I am able to make a query like select (species='dog') as isDog from animals to return 1 for dogs and 0 otherwise. How can I express this in RA? It is not selecting because we are not limiting rows. Can I use project operator even though my expression (species='dog') is not an attribute as such? Or how should I deal with this? EDIT: I want

Couchdb join two documents using key

a 夏天 提交于 2019-11-28 01:30:26
I have two documents one with tree structure and the other one relation to the first doc. Im trying to join these two doc`s by fk and pk. I couldnt get the actual results and it displays all null values. First doc { "name": "one", "root": { "level1" : { "level2" : { "level3" : { "itemone": "Randomkey1", "itemtwo": "Randomkey2 } } } }, "type": "firstdoc" } Second doc { "name" : "two", "mapBy" : "Randomkey1", "type" : "senconddoc } I`ve written a map function, which lists all the keys given a level 1 or 2 or 3 . Now I want o join this first doc and second doc using the key. Ive tried two ways

retrieve correct data from my schemas

假装没事ソ 提交于 2019-11-28 00:37:35
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)? philipxy 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 give some guiding questions tailored to your assignment. A relation (given or query result) comes

Forming a relational algebra query from an English description

六月ゝ 毕业季﹏ 提交于 2019-11-27 15:57:27
I am preparing for an upcoming test in my school. While I was going through some example questions, I got stuck with one particular question. Passenger {p_id, p_name, p_nation} with key {p_id} Flight {f_no, f_date, f_orig, f_dest} with key {f_no, f_date} Trip {p_id, f_no, f_date, class} with key {p_id, f_no,f date} and foreign keys [p_id] ⊆ Passenger[p_id] and [f_no, f_date] ⊆ Flight[f_no, f_date] The question asks: Consider classes that passengers have occupied on flights from Narita. Write in relational algebra: What are the ids of passengers who have flown from Narita in each of these

How to convert SQL to Relational Algebra in case of SQL Joins?

北慕城南 提交于 2019-11-27 06:22:36
问题 I am working on SQL and Relational Algebra these days. And I am stuck on the below questions. I am able to make a SQL for the below questions but somehow my Relational Algebra that I have made doesn't looks right. Below are my tables- Employee ( EmployeeId , EmployeeName, EmployeeCountry) Training ( TrainingCode , TrainingName, TrainingType, TrainingInstructor) Outcome ( EmployeeId, TrainingCode , Grade) All the keys are specified with star *. Below is the question and its SQL query as well

How can I find MAX with relational algebra?

大城市里の小女人 提交于 2019-11-26 23:52:19
Working with databases, how can I find MAX using relational algebra? Assuming you have a relation, A, with a single attribute, 'a' (reducing a more complex relation to this is a simple task in relational algebra, I'm sure you got this far), so now you want to find the maximum value in A. One way to do it is to find the cross product of A with itself, be sure to rename 'a' so your new relation has attributes with distinct names. for example: (rename 'a' as 'a1') X (rename 'a' as 'a2') now select 'a1' < 'a2', the resulting relation will have all values except the maximum. To get the max simply

Relational algebra - recode column values

我是研究僧i 提交于 2019-11-26 22:02:13
问题 Suppose I have a table 'animals' whose rows represent different animals and there is a column species that might have values like 'cat', 'dog', 'horse', 'cow' etc. Suppose I am only interested in whether the animal is a dog or not. In sql (at least in MySQL) I am able to make a query like select (species='dog') as isDog from animals to return 1 for dogs and 0 otherwise. How can I express this in RA? It is not selecting because we are not limiting rows. Can I use project operator even though

Couchdb join two documents using key

一笑奈何 提交于 2019-11-26 21:54:55
问题 I have two documents one with tree structure and the other one relation to the first doc. Im trying to join these two doc`s by fk and pk. I couldnt get the actual results and it displays all null values. First doc { "name": "one", "root": { "level1" : { "level2" : { "level3" : { "itemone": "Randomkey1", "itemtwo": "Randomkey2 } } } }, "type": "firstdoc" } Second doc { "name" : "two", "mapBy" : "Randomkey1", "type" : "senconddoc } I`ve written a map function, which lists all the keys given a

What is a self join for? (in english)

血红的双手。 提交于 2019-11-26 21:02:30
I already know what a self-join does. Thank you, I also read all the other computerised operational descriptions on stack overflow, so I know this is not actually a duplicate question, so please do not give me tables or join lists. What I am seeking to why it would be done (and please, not just the self-referencing employee-manager example ). In plain English, what would I seek to achieve from a self join? My usage is in a university course, and coming from a Relational Algebra angle. I have done some SQL for a few years but the instructor loves to do self-joins on tables (after renaming one

Forming a relational algebra query from an English description

萝らか妹 提交于 2019-11-26 17:22:54
问题 I am preparing for an upcoming test in my school. While I was going through some example questions, I got stuck with one particular question. Passenger {p_id, p_name, p_nation} with key {p_id} Flight {f_no, f_date, f_orig, f_dest} with key {f_no, f_date} Trip {p_id, f_no, f_date, class} with key {p_id, f_no,f date} and foreign keys [p_id] ⊆ Passenger[p_id] and [f_no, f_date] ⊆ Flight[f_no, f_date] The question asks: Consider classes that passengers have occupied on flights from Narita. Write