** Just using regular SQL, would this solution be correct?**
Design a database for the following scenario: You need to track all of the dogs at an agility competition. They have different events for each competition and each dog has a score from each event. Also, write the SQL queries to return all the dogs in the competition, the events that each dog are enrolled in, and the score that they received in that event.
CREATE TABLE Dogs (
Name STRING,
EventId INT
)
CREATE TABLE Events (
Name STRING,
Id INT
)
CREATE TABLE Scores (
Score INT,
EventId INT
)
SELECT name
FROM Dogs
INNER JOIN Events On Events.Id = Dogs.EventId
INNER JOIN Scores On Events.Id = Scores.Event.Id
Scoresyou only haveEventIdandScore, so you can only have one score per event. I think many dogs will attent an event, and each dog will have it's individual score.LEFT JOINas a dog doesn't have to get a score (didn't finish, for example).