S
Support
I have two databases with the following schema (main fields named only).
I need to merge them into one database & I am a little stuck on how best to
proceed.
PK= Primary Key/ FK= Foreign Key
DB1
DB2
tblCustomers
tblCustomers
g_user_id
g_user_id
source_customer_id
PK
order_group_id
PK
new_user_id
order_number
order_group_id
order_number
tblOrders
tblOrders
customer_guid
FK/PK
order_group_id
source_customer_id
order_number
FK
new_user_id
order_group_id
order_number
PK
new_order_id
tblOrderlines
tblOrderlines
order_number
FK
order_id
order_id
FK
new_order_id
DB1 is comprised of 2 differing databases from 2 different order systems
which is why there is some duplication
DB2 is the new ordering system and is the final design I am intending to aim
for.
On DB1, I have a 1:Many relationship between tblCustomers and tblOrders. I
have a 1:many relationship between tblOrders and tblOrderlines
On DB2, I have a 1:1 between tblCustomers and tblOrders and 1:many between
tblOrders and tblOrderlines.
I think I should aim to get the new_order_id of tblOrders (DB1) to also be
present in tblCustomers of DB1.
(NB: To create new_order_id in tblOrders I created a combination of
order_group_id and order_number. I cannot do this in tblCustomers as the
data is different)
So in order to do this I have done an update query where:
UPDATE tblCustomersDB1 INNER JOIN tblOrdersDB1 ON
tblCustomersDB1.New_User_ID = tblOrdersDB1.New_User_ID SET
tblCustomersDB1.NewOrder_ID = tblOrdersDB1!NewOrder_ID;
The problem I have is that there are 61459 records in tblCustomers (DB1) and
89649 records in tblOrders (DB1). I know that this is because a customer
has more than one order so I effectively also need to update the
tblCustomers.new_users_id with more entries (and take off the PK) and do the
update above.
How do I do this?
Thanks.
I need to merge them into one database & I am a little stuck on how best to
proceed.
PK= Primary Key/ FK= Foreign Key
DB1
DB2
tblCustomers
tblCustomers
g_user_id
g_user_id
source_customer_id
PK
order_group_id
PK
new_user_id
order_number
order_group_id
order_number
tblOrders
tblOrders
customer_guid
FK/PK
order_group_id
source_customer_id
order_number
FK
new_user_id
order_group_id
order_number
PK
new_order_id
tblOrderlines
tblOrderlines
order_number
FK
order_id
order_id
FK
new_order_id
DB1 is comprised of 2 differing databases from 2 different order systems
which is why there is some duplication
DB2 is the new ordering system and is the final design I am intending to aim
for.
On DB1, I have a 1:Many relationship between tblCustomers and tblOrders. I
have a 1:many relationship between tblOrders and tblOrderlines
On DB2, I have a 1:1 between tblCustomers and tblOrders and 1:many between
tblOrders and tblOrderlines.
I think I should aim to get the new_order_id of tblOrders (DB1) to also be
present in tblCustomers of DB1.
(NB: To create new_order_id in tblOrders I created a combination of
order_group_id and order_number. I cannot do this in tblCustomers as the
data is different)
So in order to do this I have done an update query where:
UPDATE tblCustomersDB1 INNER JOIN tblOrdersDB1 ON
tblCustomersDB1.New_User_ID = tblOrdersDB1.New_User_ID SET
tblCustomersDB1.NewOrder_ID = tblOrdersDB1!NewOrder_ID;
The problem I have is that there are 61459 records in tblCustomers (DB1) and
89649 records in tblOrders (DB1). I know that this is because a customer
has more than one order so I effectively also need to update the
tblCustomers.new_users_id with more entries (and take off the PK) and do the
update above.
How do I do this?
Thanks.