nathanstevenson
IS-IT--Management
Hi,
I have built a database with autonumbers, to test whether or not it is better to use them. I have all my data in one big table with 28 different columns and 280 lines (for testing purposes). I want to split it up and distribute it into 8 different tables.
How do I maintain relationships if the primary ID on the staging table is "lower-down" on the list of one-to-many tables. I.E. it is on the many side.
For example, One of the tables is Manager, which has fields Division, Department,Cost Centre and Manager Name.
Manager has a one-to-many relationship with table Contractor. Contractor has fields, Contractor Name and Agency. Contractor has a one-to-many relationship with Timesheet, which has fields Hours Worked, Rate, Vat and Total.
It looks like this:
Manager -------------->Contractor----------->Timesheet
one 2 many one 2 many
The problem arises in that the imported data is comprised of all details recorded on timesheets which only leaves me with a possible primary key for timesheet. How do I append to Manager and contractor and finally to timesheet while maintaining the relationships?
Is there something simple I am missing here? Or is the only solution to write some code that will check for unique values over x fields, spit that out into it's destination table, insert a column in the imported data table, then update the imported data table with the primary key ID from the destination table where all x fields are equal to all x fields in import table?
If so, how would you do this?
Any help would be highly appreciated!
Thanks,
Nathan
I have built a database with autonumbers, to test whether or not it is better to use them. I have all my data in one big table with 28 different columns and 280 lines (for testing purposes). I want to split it up and distribute it into 8 different tables.
How do I maintain relationships if the primary ID on the staging table is "lower-down" on the list of one-to-many tables. I.E. it is on the many side.
For example, One of the tables is Manager, which has fields Division, Department,Cost Centre and Manager Name.
Manager has a one-to-many relationship with table Contractor. Contractor has fields, Contractor Name and Agency. Contractor has a one-to-many relationship with Timesheet, which has fields Hours Worked, Rate, Vat and Total.
It looks like this:
Manager -------------->Contractor----------->Timesheet
one 2 many one 2 many
The problem arises in that the imported data is comprised of all details recorded on timesheets which only leaves me with a possible primary key for timesheet. How do I append to Manager and contractor and finally to timesheet while maintaining the relationships?
Is there something simple I am missing here? Or is the only solution to write some code that will check for unique values over x fields, spit that out into it's destination table, insert a column in the imported data table, then update the imported data table with the primary key ID from the destination table where all x fields are equal to all x fields in import table?
If so, how would you do this?
Any help would be highly appreciated!
Thanks,
Nathan