Skip to content

Conversation

@aaronev
Copy link
Owner

@aaronev aaronev commented Mar 13, 2017

No description provided.

DROP TABLE IF EXISTS friend;
CREATE TABLE friend (
id1 INTEGER REFERENCES student(id),
id2 INTEGER REFERENCES student(id),

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)





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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants