sql - database design -


IM is building a database that records details from many forms and each form has a status and an amendment. I want to create a table which holds all the modification and position data for all the forms, although something stuck with the design and how can I define relationships between form tables and 1 amendment and status table.

The tables I have are as follows: Collapse tables for simplicity

  Task --------- pk int id briefs --------- pk int id Revisions --------- fk formId int status   

I want to add a task table and a brief table to the amendment table But obviously there will be a conflict with PK, like the Guardian tables review table, the best option is to use a look-up table and work and briefly The modification in the archive of the primary key of the table.

Thank you in advance

option 1 :

Create a form table, which is the central source of form ID, when I enter in the work / summarized / etc. (I think it may be too much), then insert it in the form table for the first time, then Use the ID as work or in the form of PK / FK.

Then in your review, the form ID only references the form ID in the form.

You probably want to record the form type in the form table, and possibly apply that if you have inserted the "1, work" that you have the table table to include in the table work table There are ways to do this.

You also want to hide some of these facts behind thoughts / triggers (so you put them in work, and put it behind the scenes in the form, etc.).

Option 2 :

Create a column per table in the revision table. Add an obstacle such that none of these columns are empty. This allows you to use more specific foreign key constraints (unlike option 1, where form has a form ("1, work"), you can not guarantee that there will be a row in the work table). But if you are adding new form types, then you have to add more columns for modifications.

There are some other options, but these are two that keep spring in mind.

Comments