I'm a beginner and I want to know what is the best way for the architecture of a bdd, I give you an example:
I have a user table:
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`email` varchar(255) NOT NULL,
`pseudo` varchar(50) NOT NULL)
In my process I have some survey who have a state waiting,work,ended
and I need to store the ID of the survey too.
So the first possibility is to create a table survey who have this value :
CREATE TABLE `user_survey` (
`id` int(11) NOT NULL,
`userId` int(11) NOT NULL,
`state` smallint(3) NOT NULL)
But in my backend I need to question 2 time if I want take the user, and search for his surveys.
The second possibility is to add a row in user
table called survey
and store the data like this : surveyId,stateSurvey;surveyId,stateSurvey
etc. And iterate this data in my backend to search all survey I need.
What is the best practice/way to get this kind of data. And there is other way more "simple"?