Database - relational algebra Here is the table: CREATE TABLE User ( tag email p
ID: 3792074 • Letter: D
Question
Database - relational algebra
Here is the table:
CREATE TABLE User (
tag
email
password
signup_date
address_number
address_street
address_city
address_state
address_country
address_mailcode
PRIMARY KEY (tag)
);
-- Stores Bird specific information.
CREATE TABLE Bird (
btag
gender
first_name
last_name
birthdate
Income
PRIMARY KEY (btag),
FOREIGN KEY (btag) REFERENCES User (tag) ON DELETE CASCADE
);
Print the tag, email address, signup date, first name, and last name of Birds whose first name is ‘Hillary’.
a) [6pts] Relational Algebra
Explanation / Answer
Given tables are:
1. User
CREATE TABLE User (
tag
email
password
signup_date
address_number
address_street
address_city
address_state
address_country
address_mailcode
PRIMARY KEY (tag)
);
2. Bird
CREATE TABLE Bird (
btag
gender
first_name
last_name
birthdate
Income
PRIMARY KEY (btag),
FOREIGN KEY (btag) REFERENCES User (tag) ON DELETE CASCADE
);
Q. Print the tag, email address, signup date, first name, and last name of Birds whose first name is ‘Hillary’.
Ans:
SELECT A.tag, A.email, A.signup_date, B.first_name, B.last_name
FROM A.User, B.Bird
WHERE
B.first_name = 'Hillary'
AND
A.tag = B.btag;
Explanation:
The fundamental operations of relational algebra are as follows
We are using Project and Tuple Relational Calculus.
1. Project Operation ()
It projects column(s) that satisfy a given predicate.
Notation A1, A2, An (r)
Where A1, A2 , An are attribute names of relation r.
Duplicate rows are automatically eliminated, as the relation is a set.
For example
Selects and projects columns named as first_name and last_name from the relation Bird.
2. Tuple Relational Calculus (TRC)
Filtering variable ranges over tuples
Notation {T | Condition}
Returns all tuples T that satisfies a condition.
For example
Output Returns tuples with 'first_name' from Bird who has their first_name as 'Hillary'.
Please give a "Thumbs Up" if you find this answer useful and also feel free to give a comment.
Thanks for posting the question...!!!
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.