Question: Problem 4: SQL Queries (30 pts) Consider the following relations. The primary keys are underlined while the foreign keys are in italic. User (UId, Username,

Problem 4: SQL Queries (30 pts) Consider the following relations. The primary keys are underlined while the foreign keys are in italic. User (UId, Username, Password, Profile, Brief, Joindate) Post (Code, Title, Details, PublishDate, views, status, type) Comment (UId, PostCode, Description, commentDate) Write the corresponding SQL queries for the below questions

1. Write a query to retrieve the Username and Profile of all Users ordered alphabetically.

2. Write a query to find the titles of post having status pending and published after 1/1/2022.

3. List the username of user which contains a.

4. Find the username of user who comments on post having code 110 and 120.

5. Write a query to Find the title of all posts and description and date of its comments.

6. List the username and title of post and description of the comment he added.

7. Find the highest number of views and average number of views of posts. 8. For each post code, list the total number of comments it has.

9. Find the post titles having more than 500 views.

10. Find the post titles with no comments.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!