Question: SQL Step 1 We've created a database for a friend networking site, with a table storing data on each person, a table on each person's

SQL Step 1

We've created a database for a friend networking site, with a table storing data on each person, a table on each person's hobbies, and a table of friend connections between the people. In this first step, use a JOIN to display a table showing people's names with their hobbies.

CREATE TABLE persons ( id INTEGER PRIMARY KEY AUTOINCREMENT, fullname TEXT, age INTEGER); INSERT INTO persons (fullname, age) VALUES ("Bobby McBobbyFace", "12"); INSERT INTO persons (fullname, age) VALUES ("Lucy BoBucie", "25"); INSERT INTO persons (fullname, age) VALUES ("Banana FoFanna", "14"); INSERT INTO persons (fullname, age) VALUES ("Shish Kabob", "20"); INSERT INTO persons (fullname, age) VALUES ("Fluffy Sparkles", "8");

CREATE table hobbies ( id INTEGER PRIMARY KEY AUTOINCREMENT, person_id INTEGER, name TEXT); INSERT INTO hobbies (person_id, name) VALUES (1, "drawing"); INSERT INTO hobbies (person_id, name) VALUES (1, "coding"); INSERT INTO hobbies (person_id, name) VALUES (2, "dancing"); INSERT INTO hobbies (person_id, name) VALUES (2, "coding"); INSERT INTO hobbies (person_id, name) VALUES (3, "skating"); INSERT INTO hobbies (person_id, name) VALUES (3, "rowing"); INSERT INTO hobbies (person_id, name) VALUES (3, "drawing"); INSERT INTO hobbies (person_id, name) VALUES (4, "coding"); INSERT INTO hobbies (person_id, name) VALUES (4, "dilly-dallying"); INSERT INTO hobbies (person_id, name) VALUES (4, "meowing");

CREATE table friends ( id INTEGER PRIMARY KEY AUTOINCREMENT, person1_id INTEGER, person2_id INTEGER);

INSERT INTO friends (person1_id, person2_id) VALUES (1, 4); INSERT INTO friends (person1_id, person2_id) VALUES (2, 3);

What would be the correct SQL code to write here?

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!