Search code examples
mysqlsurvey

Matching survey database and member database


I'm new to programming, and hope this question isn't too basic. I've searched the questions here but can't find anything exactly like it.

I'm making a website in which people have to complete a sign-in form and then answer a survey. The survey answers will drive how the site performs for each user (there will be different monthly reminders in email personalized to the survey responses). I have two MySQL databases, one for the sign-in and one for the survey.

How do I get the member ID in the member database to be the same as the survey ID in the survey database? Or am I thinking about this all wrong, and there's another solution?

I'm most familiar with PHP and JavaScript, so I hope that there will be a way to do this in the coding if not in the database design. Again, sorry if this is too basic and many thanks in advance for your help.


Solution

  • This is a terribly generic question to answer, but I hope I can help you a little along:

    Now, assuming that you have a good reason for separating the user registration and the surveys in two different databases (you did not give a reason for it being so), after a successful user registration you can assume that the user is 'logged in'. This should mean that the ID of the registered user is available to you in code.

    You do not have to have identical survey IDs and user IDs, it usually makes more sense to have a separate table knitting users and surveys together (with a user_id field and a survey_id field).

    After setting up or saving the survey, store a record in this table, connecting the user with the survey.

    If you were hoping for a more specific answer, I suggest you delve into a little more detail in your question.

    Good luck!