Hi StackOverflow community,
I have these two tables:
tbl_users
- ID_user (PRIMARY KEY)
- Username (UNIQUE)
- Password
- ...
tbl_posts
- ID_post (PRIMARY KEY)
- Owner (UNIQUE)
- Description
- ...
Why always everybody make database relationships with foreign keys? What about if I want to relate Username with Owner instead of doing ID_user with ID_user in both tables?
Username is UNIQUE and the Owner is the username of the creator of the post.
Can it be done like that? There is something to correct or make better? Maybe I have a misconception.
I would appreciate detailed and understandable answers.
Thank you in advance.
Aucun commentaire:
Enregistrer un commentaire