Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given the following relational database schema: Users ( uid , name, school, year, age ) Friends ( uid 1 , uid 2 ) Foreign key

Given the following relational database schema: Users(uid, name, school, year, age)
Friends(uid1, uid2)
Foreign key(uid1) references Users(uid) Foreign key(uid2) references Users(uid)
Posts(pid, uid, text, datetime, rating)
Foreign key(uid) references Users(uid)
Likes(uid, pid, datetime)
Foreign key(uid) references Users(uid) Foreign key(pid) references Posts(pid)
Write SQL commands to achieve each of the following requests [5 points for each]:
1) Retrieve each post text and the name of the user who has posted it.
2) Retrieve the text of each post that has been posted by any person who is enrolled at UTD (school).
3) Retrieve the names of all the friends of the user John Smith.
4) Retrieve the name of each user if he/she has posted any text that talks about UTD.
5) Retrieve the name of user who does not have any post.
6) Retrieve the name of each user and the number of friends he/she has.
7) Retrieve the name(s) of the user(s) who has the maximum number of posts.
8) Remove every fact that indicates that the user with the name John Smith likes posts that were posted by the user whose name is Tom Harper.
9) Increase the rating by 1 for every post that has been posted by any user whose age is more than 80.
10) Prevent any user of age below 12 from posting any text.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions