Relational database parent-child with parent partially dependent on child for information to be complete

114 Views Asked by At
form_id date_submitted
1 10/08/22
completer_id name signature form_id
1 Tom 38ehdsdj 1

I have a digital form that is submitted and stored in my SQL database. There are two tables that are relevant to my question. The 'forms' table, which includes form_id and date_submitted (forget any form input data exists for this question). I also want to store the unique employee email of the person who submitted the form, and also the signature that they made on the form. If it was just their email, I'd just have another column within the forms table. However, the signature has to be collected for each form submission by that person (the whole point of a signature, to verify it). Since signature belongs to the person, I've created a second table called form_completers, with four columns: completer_id, name, signature, and form_id (foreign key to forms table). Since the form_completers table references the forms table, form_completers is the child. From my understanding, parents should be able to exist and make sense independent of children. If a forms_completer entry was to be removed, the data for the form would be incomplete, so in a way the parent (forms) is dependent on the child (forms_completer) in order for the form data to be complete. Am I thinking about this in the right way?

1

There are 1 best solutions below

4
Bohemian On

Delete the form_id column from completers.

Add a completers_id column to forms.

A person can complete many forms, but a form has exactly 1 completer.