-
Notifications
You must be signed in to change notification settings - Fork 0
forgetful-elephant - 178 core sql solo #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: empty2
Are you sure you want to change the base?
Conversation
| DROP TABLE IF EXISTS friend; | ||
| CREATE TABLE friend ( | ||
| id1 INTEGER REFERENCES student(id), | ||
| id2 INTEGER REFERENCES student(id), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A clearer naming structure for a join table would be something like:
student_friends (includes a reference to the student table in the table name)
id (the primary key of the student)
friend_id (the primary key of another student)
It might seem a little redundant to differentiate between the two student ids, but it would allow you to select all of a student's friends using something like:
SELECT friend_id FROM student_friends WHERE id = (studentId)|
|
||
|
|
||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This much whitespace doesn't make it any clearer why you're breaking up the queries, so it isn't really helpful - A better way to separate them would be with a comment line to explain the difference, or by making 09-mutual-likes a directory and separating the queries into different sql files inside that directory.
No description provided.