Hi,
First of all, i'm sorry for my poor english.
I have following Problem:
"I want to store incoming and outcoming documents. Documents are of particular type (i.e. HR docs, Personal files, Medical Documentation itp.). Each type of document has different unique data that i want to store and there is a few basic data which is the same for every type of document."
I have created tables for this:
Code:
t_doctypes { PK:id_doctype, description }
Code:
t_inbox {PK:id_document, id_doctype, id_sender, createdate, is_valid}
Code:
t_doc_l4 {PK:id_docdetails, id_document, field1, field2 ... other fields}
Code:
t_doc_l5 {PK:id_docdetails, id_document, field3, field4 ... other fields}
Now what i want is :
1. Relationships (1:1) between t_inbox and t_doc_l4, t_doc_l5
-> because one document in t_inbox has exactly one details record in only one of the tables (t_doc_l4 or t_doc_l5)
-> because i want to automatically delete linked rows
2. triggers on tables t_doc_l4, t_doc_l5
-> when the user adds a new document of type "L4" i want to automatically add a new record to t_inbox and update field t_doc_l4.id_document with value id_document of new record in t_inbox
Example of valid data in the tables:
t_inbox:
(id_document, id_doctype, ...)
1, "L4", 2011-05-10,...
2, "L5", 2011-05-12,...
3, "L5", 2011-05-13,...
4, "L4", 2011-05-16,...
t_doc_l4:
(id_docdetails, id_document, ...)
1, 1, ...
2, 4, ...
t_doc_l5:
(id_docdetails, id_document, ...)
1, 2, ...
2, 3, ...
Please help me with this.
1. I don't know if i designed tables right
2. I don't know how to create correct relationships
3. I tried to create trigger "After insert" but in that section access do not allow to update values of newly created record. how to do that?
Thank You for any help