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

  • SEARCH
  • Home
  • 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 9154347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:24:50+00:00 2026-06-17T12:24:50+00:00

I have 2 database tables below I am thinking of creating: Question Table: QuestionId(PK)

  • 0

I have 2 database tables below I am thinking of creating:

Question Table:

QuestionId(PK)  QuestionNo  QuestionContent  SessionId (FK)
11              1           Question1        3    
12              2           Question2        3
13              3           Question3        3

Image_Question

ImageId (PK)  SessionId (Fk)  QuestionNo (FK)
1              3               1
2              3               2

Because of the way I set up an image upload, the user can upload images to a question before the question is submitted into db, so only way to determine which question an image belong to in my html was to use the QuestionNo in the html to know which question uploaded the image file as QuestionId is not entered until page is submitted.

My question is that is it possible to have 2 non unique fields as foreign keys?

Also if I just set SessionId as (FK) on its own and if QuestionNo allows (FK), that is set on its own thn prblem I have as that as there are multiple sessions with same QuestionNo, if I click on a QuestionNo above, it could displays rows for the same QuestionNo in all sessions that contain thatQuestionNo.

My other question will be how to combine SessionId and QuestionNo (FK) so that if I search under QuestionNo, it searches for that QuestionNo in the relevant SessionId? If I click on the SessionId then it displays details for that SessionId so that is ok.

  • 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-06-17T12:24:51+00:00Added an answer on June 17, 2026 at 12:24 pm

    I find your question a little hard to understand, but from what I can gather you are using QuestionNo as a temporary token to link several http requests together (image uploads + question post).

    I suggest something like:

    SessionQuestionToken
    {
      Token
      SessionId
    }
    
    Image
    {
      ID
      QuestionId FK references Question(Id)
      ImageName
    }
    
    Question
    {
      Id
      Content
    }
    
    TempImage
    {
      Token FK references SessionQuestionToken(token)
      ImageName
    }
    

    And the logic like so:

    1. User requests question form. Server sets token and includes in response to user.
    2. User uploads picture including token. Image is stored in temporary table.
    3. Step 2 repeated n times.
    4. If user submits question with token value, an entry is placed in the questions table and an id is assigned. All images in the TempImage table that share the token get inserted to the image table with the now known QuestionId. The SessionQuestionToken entry is then deleted and cascade deletes the temp images in TempImage.
    5. Else user doesn’t submit question then files are deleted and SessionQuestionToken entry deleted.

    As for your question if foreign keys can still reference non unique columns, the answer is yes.

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

Sidebar

Related Questions

I have two database tables below: Course_Module Table: CourseId ModuleId 1 1 1 2
I have two database tables with some demo data like shown below Create table
I have 10 tables in my database(MySQL). two of them is given below tbl_state
Consider the below situation I have a database table as below user_id user_rank ------------------
I have a mysql database with a table structure like below : Table Name
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have the following listbox below which binds to a database table of image
need help in error in database pivot. i have table tamed table_score like below:
i have a question about basic mysql database optimisation. I have 3 tables, Articles,
I have two database tables: Definitions table has the following columns: Id, Category Sample

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.