Hi
Im working on a future model at work. And i'm not quite sure how to do this, because the solution I have seems bad.
Basicly I want to take input data and store it to a mssql database. Simple enough.
I have 2 tables.
Table 1.:
Orders
id - primary key, identity 1
parcelnumberpurchase
creditornumber
shipmentyear
bookinglineid
Table 2.:
OrderDetails
id - primary key, identity 1
parcelnumberpurchaseid FK - table 1 parcelnumberpurchase
amount
quantity
currency
We do the same base data - YTD incl. new month, every month. But we often change something in our models, so I want 1. check if the parcelnumberpurchase excist on the same creditor the same shipmentyear.
If not, then insert it.
1.: Then I want that id on my 2. table. But do I need to query my table 1, and join the id on table 2?
2.: If the data on a parcelnumber changes - i would like to delete the data from table 2 for that parcelnumber and add the new one. Can I do that?
Thanks you very much