How should I structure my database?

Asked

Viewed 54 times

-1

I am studying Mysql and have a user system. When the user logs into the account it is possible to create annotations. I imagine the right user table, but what about the notes? Should I create a table just for them and use Foreign Keys? What do I do?

  • 4

    Yes creates a table only for users, with username, name, email ,... next creates another for annotations and uses Foreign key, inside this table also inserts the user_id field (in this case it would be the Foreign key) that will allow knowing whose annotations will be, I do not know if I made myself understand, but basically this, you will have to put in the table "annotations" an equal field that will connect the two

1 answer

0


It would be interesting in the annotations table if you had a foreign key for the user table, so you know that that annotation belongs to that user, that is, in the annotations table you would have an id_usuario column containing the id of that user who made the annotation, thus all annotations containing this id have to this user. I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.