Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 794513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T22:19:30+00:00 2026-05-14T22:19:30+00:00

I don’t even know if that’s the right term. May it be known that

  • 0

I don’t even know if that’s the right term.

May it be known that I’m a major novice!

I have three tables: users, profiles, and survey. Each one has user_id as it’s first field, (auto-increment for users), and they’re all tied by a foreign key constraint, CASCADE on DELETE.

Currently, for each user, let’s say user_id 1, they have a corresponding db entry in the other tables. For profiles it lists all their information, and the survey table holds all their survey information.

Now I must change things…darn scope creep. Users need the ability to have multiple survey results. I imagine that this would be similar to a comment table for a blog…

My entire app runs around the idea that a single user is linked to a constraining profile and survey.

How should I structure my db?

How should I design my app’s db so that a user can have multiple tests/profiles for the test?

Please assist! Any advice, information and personal-knowledge is appreciated!

Right now the only way I know how to accompany my client is to create a pseudo-user for each test (so unnecessary) and list them in a view table (called "your tests")— these are obtained from the db by saying: where user_id=manager_id

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T22:19:31+00:00Added an answer on May 14, 2026 at 10:19 pm

    Right now, survey has a foreign key to user, identifying the user who took the survey. This is good, and does not change.

    But add an autoincrement primary key to survey (and to profile, too). Now a user can have multiple surveys. Each individual survey has its key, and its taker is identified by the user foreign key.

    To find all surveys for all users:

    select a.*, b,* 
    from user a 
    join survey b on (b.user_id = a.user_id);
    

    To find all surveys for one user:

    select a.*, b,* 
    from user a 
    join survey b on (b.user_id = a.user_id)
    where a.user_id = some_user_id;
    

    To just get the survey data, just select b.* only. For example:

    select b.* 
    from survey b on 
    where a.user_id = ( select user_id from user a where a.name = 'Bob' );
    

    Again, all you need to do is add a primary key (which should be an autoincrement) to survey.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't know if this has been answered before. Have custom routes to users. If
Don't know the term for the red validation border, does it have one? I
I don't know if this is a well known 'thing' or something new in
Don't know if I worded the question right, but basically what I want to
Don't know if anyone can help me with this or if it's even possible.
Don't overthink this - there's a very commonly used term and I ... have
Don't know if this is the right place to ask this, but I will
DON'T ASK WHY but... I have a regex that needs to be case insensitive
I don't have much PHP experience and I want to know how to best
Don't yell at me! i have seen many threads claiming that HTML cannot be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.