Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MYSQL coding help Attached are pictures of the database, tables and content with

ID: 3823728 • Letter: M

Question

MYSQL coding help

Attached are pictures of the database, tables and content within the database.

Task 1: Insert Records to Image Table Construct the SQL statement to insert 5 new records in the “image” table.

Task 2: Insert Records to Message-Image Table Construct the SQL statement to insert 5 new records in the “message_image” intersection table. Note: You are required to add at least one record where at least one of Michael Phelp's messages includes at least one image. Also, you are required to add at least one message that has multiple images.

Task 3: Find All of the Messages that Michael Phelps Sent Construct the SQL statement to find all of the messages that Michael Phelps sent. Note: You must use the WHERE clause to set the conditions for this query.
Display the following columns:
- Sender's first name
- Sender's last name
- Receiver's first name
- Receiver's last name
- Message ID
- Message
- Message Timestamp

Task 4: Find the Number of Messages Sent for Every Person Construct the SQL statement to find the number of messages sent for every person. Note: You must use the WHERE clause to set the conditions for this query.
Display the following columns:

- Count of messages
- Person ID
- First Name
- Last Name

Task 15: Find All of the Messages that Have At Least One Image Attached Using INNER JOINs Construct the SQL statement to find all of the messages that have at least one image attached using INNER JOINs. Note: For messages with multiple images, display only the first image for the message.
Display the following columns:

- Message ID
- Message
- Message Timestamp
- First Image Name
- First Image Location

mysql> SHOW TABLES; I Tables in messaging I contact list image I message I message image I person 5 rows in set (0.00 sec)

Explanation / Answer

TASK 1

TASK 2

TASK 3

select message_id, sender_id, receiver_id , message, send_datetime from message where sender_id in

(select person_id from person where first_name like 'Michael' and last_name like 'Phelps');

TASK 4

select count(message_id) , sender_id, first_name, last_name from message,person group by sender_id having person_id = sender_id ;

TASK 5

select message_id,image_name,image_location,message,send_datetime from image inner join message_image on image.image_id= message_image.image_id inner join message on message_image.message_id=message.message_id

If found any error in the queries, please write in the comment section to let me know, so that I can resolve it.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote