Hi.
Quote:
Originally Posted by Annalyzer
If you put the username in the asteroid table, then that asteroid can only be assigned to one user creating a one-to-one relationship. Each one asteroid belongs to one user.
I would have though that would be a one-to-many (1:N) relationship; each user being able to own multiple asteroids.
But yea. If you only want each asteroid to be linked to a single user then you would create a one-to-many (1:N) relationship.
Meaning; putting the PK of the user table into the asteroid table as a foreign key.
If you want each asteroid to be linked to multiple users, then you would need a many-to-many (N:M) relationship, which would require a intermediary table (link table).
I would advise you to use an integer as a PK in your user table, rather then using the username. That way you would only have to put the integer into the asteroid table, rather then the username, which will both safe disk space and speed up your queries.
(String comparison is a lot more complex then integer comparison)