Last post Jan 22, 2019 03:27 AM by Wei Zhang
Jan 21, 2019 02:35 AM|asplearning|LINK
Hello everyone, normally when I use datatype int as my primary key, I can design my table to something like this:
application_id (primary key), run_id, date_create, application_name, parent_application_id (nullable)
The parent_application_id is a foreign key of the application_id in the same table.
Now I have a situation where I need to take out application_id and use composite columns (run_id, date_create) to create a primary key to something like this:
run_id, date_create, application_name, ???
How do I design the parent_application_id in this case? Is it possible?
Jan 21, 2019 06:06 PM|PatriceSc|LINK
Then you would need parent_run_id, parent_date_create and parent_application_name so that this fk triplet can match your pk triplet...
Make sure this is needed. Maybe a unique index could be enough or this table should be splitted ? (not sure what you call a "parent" application, this is to handle installing multiple instances of a single application ?)
Jan 22, 2019 03:27 AM|Wei Zhang|LINK
Hi asplearning ,
According to your description ,if you want to use composite columns (run_id, date_create) to create a primary key , you should also create columns like parent run_id,parent date_create as composite foreign key.
Your table should at least:
run_ id , date_create ,application_name, parent run_id, parent date_create