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 1027145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T12:11:44+00:00 2026-05-16T12:11:44+00:00

This is how my tables look: tableMembers | memberID as primary key tableAddress |

  • 0

This is how my tables look:

tableMembers | memberID as primary key

tableAddress | addressID as primary key references memberID

tableSubscription | subsID as primary key references memberID

This database is for a subscription site. Basically, if a row is inserted into tableMembers, a corresponding row is inserted to each of the other tables.

I set up foreign keys for the last two tables so I can access them in relation to tableMembers. Basically if I access a row from tableAddress I do:

SELECT * FROM tableAddress WHERE addressID = (SELECT memberID FROM tableMembers WHERE uname = 'John'); 

The problem with my setup is that, when synchronization of ID’s gets messed up, foreign keys would no longer work. Say, when I insert a row into tableMembers and then tableSubscription becomes dysfunctional for few seconds for some weird reasons? Or in case of a user signing up (latest memberID becomes = 2), say he/she doesn’t subscribe which leaves subsID (which remains = 1) unsynchronized with memberID. And later on, a new user signs up (latest memberID becomes = 3) and subscribes (subsID becomes = 2). That makes my query above obselete. How do I prevent this kind of scenario? Or please enlighten me if you think I don’t understand the concept of foreign keys.

  • 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-16T12:11:45+00:00Added an answer on May 16, 2026 at 12:11 pm

    Make sure that only one of the tables have an autoincrementing id. The others should get their id from the insert query, from the application code, to make sure they are for the correct member.

    In pseudo-code:

    1. User signs up and get an
      autoincremented id of 3.
    2. Check the
      id with last_insert_id()
    3. User
      subscribes to something. The id in
      the tableSubscription table should
      be set by your application code to
      the value you got earlier.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My tables look like this: qotwQuestion1a QuestionId [primarykey] Question MemberId PostDate qotwVote1a QuestionId [primarykey]
I have a database that has two tables, these tables look like this codes
I have 2 tables which in simplified form look like this: Products( id: int,
i've got this tables in my database. alt text http://img166.imageshack.us/img166/3133/testdbschemafy5.png With Entity Framework i
My two tables look like this: TABLE1 TABLE2 +--------------------+ +--------------------+ |field1|field2|field3| and |field2|field4|field5| +--------------------+
I have three tables: videos, videos_categories, and categories. The tables look like this: videos:
I have 3 tables that look like this: tblVideo: VideoID | Video Name 1
I have two tables that look like this: Table: cases id name status case_no
I have a SQL Server 2008 database. This database has two related tables: Customer
To give you a bit of context, my database tables look like so: User

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.