MySQL Forums
Forum List  »  Newbie

Table Schema - Inner Joins
Posted by: Joseph Longo
Date: January 12, 2022 02:53PM

Hello all,

I need some assistance in designing my tables for a project I am working on. I am stumped on which foreign keys to include in which table, in order to join them correctly.

I have a users table, a cases table, and a supplements table. One user can have many cases, and one case can have many supplements. I am creating a "tracking" program which stores the users id, case number, and various dates the case is supplemented. The purpose of the tracking program is to email/text the user a reminder their case needs to be supplemented after X amount of days have elapsed. For instance:

User: Apu Nahasapeemapetilon ---> Case: 12345-67890 ---> Supplement dates: 01-01-2022, 01-06-2022, 01-08-2022, etc.

So, *thinking out loud* the cases table would need to include the users id from the users table as a foreign key so each user access their case...right?

Here's where I get stumped...

What foreign keys should I include in my supplements table? Should I only include the cases ID, or do I need to include the users ID along with the cases ID in the supplements table, too?

Options: ReplyQuote

Written By
Table Schema - Inner Joins
January 12, 2022 02:53PM

This forum is currently read only. You can not log in or make any changes. This is a temporary situation.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.