This task concerns the following tables:PersonsidnameaddressageeyeColorgenderClassesidkindTakesClassesidperson_id → Personsclass_id → ClassesWrite a query that returns the table with the name of persons and the kind of classes that they take. The columns of the resulting table should be:ResultsnamekindFor example, if George Orwell takes the classes "dancing" and "baking", then the result should contain rows (George Orwell, dancing) and (George Orwell, baking).
Question
This task concerns the following tables:PersonsidnameaddressageeyeColorgenderClassesidkindTakesClassesidperson_id → Personsclass_id → ClassesWrite a query that returns the table with the name of persons and the kind of classes that they take. The columns of the resulting table should be:ResultsnamekindFor example, if George Orwell takes the classes "dancing" and "baking", then the result should contain rows (George Orwell, dancing) and (George Orwell, baking).
Solution
To achieve this, you would need to join the three tables together using SQL. Here is a step-by-step guide on how to do this:
-
Start by selecting the columns you want to display in your final result. In this case, you want the 'name' column from the 'Persons' table and the 'kind' column from the 'Classes' table.
-
Next, you need to specify from which table you want to start pulling data. Let's start with the 'Persons' table.
-
Then, you need to join the 'TakesClasses' table on the 'id' column of the 'Persons' table and the 'person_id' column of the 'TakesClasses' table.
-
After that, you need to join the 'Classes' table on the 'id' column of the 'Classes' table and the 'class_id' column of the 'TakesClasses' table.
-
Finally, you need to display the result.
Here is the SQL query that does all of this:
SELECT Persons.name, Classes.kind
FROM Persons
JOIN TakesClasses ON Persons.id = TakesClasses.person_id
JOIN Classes ON TakesClasses.class_id = Classes.id;
This query will return a table with the names of persons and the kinds of classes they take.
Similar Questions
This task concerns the following tables:PersonsidnameaddressageeyeColorgenderTakesClassesidperson_id → Personsclass_id → ClassesWrite a query that returns a table with columns name and nrOfClasses that contains the list of all names of people and the number of classes that this person takes.NoteYou can give names to columns in the SELECT clause by SELECT … as someName.
This task concerns the following tables:PersonsidnameaddressageeyeColorgenderKnowsidpersonA_id → PersonspersonB_id → PersonsThe semantics of the Knows table is that the person referenced by personA_id knows the person referenced by personB_id.TakesClassesidperson_id → Personsclass_id → ClassesThe semantics of the TakesClasses table is that person referenced by person_id takes the class referenced by class_id.Use NOT IN to write a query that returns the name of all persons that do not know anyone who takes classes.
What are the steps needed to write a class that is mapped to a database table? Select all that apply.Group of answer choicesMatch the names of the table's columns to the attributes of the classMatch the names of the table's columns to class variablesCreate a table with the exact same name as the classCreate a table with the same name as the class, but pluralizedI don't know
This task concerns the following tables:PersonsidnameaddressageeyeColorgenderSportTogetheridsportpersonA_id → PersonspersonB_id → PersonsThe semantics of the Sport table is that personA does sport with personB.CautionNote that the table does not contain redundancies. The table may contain a row (id, sport, personA, personB) without containing the symmetric row (id, sport, personB, personA). Nethertheless, the relation is to be understood as symmetric: if personA does sport with personB, then of course personB also does sport with personA! You need to take this into account in your query!Write a query that returns a table with columns: name and rugby. The table should contain the names of all people and the columns rugby there should contain "Yes" or "No" depending on whether this person plays rugby or not.
You are given the following tables:CourseCourseID Description CreditsCS101 Computer Science I 3CS201 Elementary Data Structures 3ENGL210 Technical Writing 3RegistrationSID CourseID SemID Instructor Grade282712 ENGL210 201701 H. Zacny B+362112 CS101 201701 K. Ross CWhat would the following SQL Select statement produce for output?select course.description, registration.SID,registration.gradefrom registration right join courseon registration.courseID = course.courseIDSelect one:a.Computer Science I 362112 Cb.Computer Science I 362112 CTechnical Writing 28212 B+c.Computer Science I 362112 CElementary Data Structures null nullTechnical Writing 28212 B+d.No results due to syntax errorClear my choiceSkip Quiz navigationQuiz navigationQuestion1Question2Question3Question4Question5Question6Question7Question8Question9Question10Question11Question12Question13Question14Question15Question16Question17Question18Question19Question20Question21Question22Question23Question24Question25Question26Question27Question28Question29Question30Question31Question32Question33Question34Question35Question36Question37Question38Question39Question40Question41Question42Question43Question44Question45Question46This pageQuestion47This pageQuestion48This pageQuestion49This pageQuestion50This page
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.