This worksheet contains questions relating to relational algebra.
Some of the answers will require you to type relational algebra expressions such as
To write these in text, do the following
So you will type
pi_id(sigma_(a>10) ((R bowtie S) x T))
to represent the sample relational algebra expression above.
The first few questions will use a student / unit / grade database similar to the one from lectures, but where the tables are called S (for student), U (for unit) and G (for grade) and have the following schema:
S(sid, name, gender)
U(uid, name)
G(sid, uid, grade)
Students have a unique id, a name and a gender (either M or F) , Units have an unique id (like CITS1402) and a name (like Databases), while Grades indicate what grade the student with id sid achieved when they took the unit with id uid.
Sample Question: What relational algebra expression will produce a list of all the unit ids?
Answer: The expression is
What you type: pi_uid(U)
SQL query?SELECT S.sid
FROM Student S, Grade G
WHERE S.sid = G.sid
AND grade < 50;
SQL query will produce a table with the same columns and contents as the following relational algebra expression? None of these questions involve a GROUP BY condition and so all will produce a single row from the entire table that is specified in the FROM condition. (However this table may still be constructed as theJOIN of one or more tables.)
world database? (Hint: Use only the Country table)SQL query will produce a one-row table with one column called worldPopulation with the total population of all the countries listed in the database?MySQL have? (Use the MySQL documentation to determine this.) Written with StackEdit.