Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone,
I am sorry but I am new in database, so my questions might look very easy for skilled DBA.

I have to create a new database for two companies merging:
Database A
Customer
(Customer ID(int), Name(varchar), Address(varchar), MoneyonAccount(decimal), Loanlimit(int), branchmanagerID(int) ).

Transaction
(Tranction ID(int), Transaction date(date), Customer ID(int), Loan granted date(date) ).

Transactiondetail
(Transaction ID(int), operation ID(int), Amount(decimal), bankcharge(decimal) ).

Operation
( operation ID(int), operationdescription(varchar),
 operationclass(varchar), chargeperoperation(decimal) ).

Branchmanager
( branchmanager ID(int), name(varchar), address(varchar), salary(decimal), bonus(decimal) ).


Database B
Customer
same as previous with different data and similar data such customer ID which is the primary key.

Transaction
same as previous but has added columns such as transaction motif and additional charge.

Transactiondetail
same as previous , just more data are added.

Operation
Operation ID has a different format (the previous is like 00215 and in this table it is like 46.

Branchmanager
same as in previous table


So my questions are how to create mapping of these tables?
How would look like the UML diagram of the new database?
How to combine these tables since some of them have different prmary keys and some columns are not similar or are missing?
If two primary keys are similar do I have to choose one?
How can all of the steps above done in PHPmyAdmin?

Thank you for your understanding
Posted
Updated 17-Nov-15 14:18pm
v3

1 solution

You have some different issues and here is one way you can approach them.

1. Different primary keys
You can create a new primary key and keep the old keys in a separate table.
By doing this you can still find an item with an old ID, but without messing up the table in use.

LegacyOperationLookup
OperationID   LegacyOperationID   Source
1             00215               Database1
2             46                  Database2

This depends on if you have the freedom to change the design.

2. Different columns
If you have to similar similar tables but one table has some extra columns, or if both tables have a column the other table is missing, you have at least two choices.
a. You can create a new table with the sum of all columns.
b. You can create an extra table containing the additional columns as legacy.

The trick here is to know if the extra columns are useful in the new organisation or not and also if the columns can be NULL or not.
If no one will use the additional columns it is better to keep them in a separate table.
If the additional columns cannot be NULL, you have to decide what to insert as empty values.

3. PHP Admin
See this link Merge two MySQL databases[^] or use the same phrase in Google.


4. UML Diagram
Regarding the UML diagram I will not do that for you, but just give you a pointer where you can start to learn it: TutorialsPoint: UML - Standard Diagrams[^]

I hope this gives you at least some help forward.
 
Share this answer
 
Comments
Member 12147416 18-Nov-15 1:52am    
Thank you George, yes it helped me a lot! For the UML I just wanted to understand how to show the mapping to make sure that no data is lost in transaction? Any idea?
Thank you again for your help
George Jonsson 18-Nov-15 2:46am    
Just show clearly a before-merge and an after-merge diagram.
Use bold or italic text to emphasize differences or similarities.
(Colors can also be used, but there is a risk the info get lost in a B&W print)
Member 12147416 18-Nov-15 3:12am    
Ohh! as simple as that? Thank you very much.
Just one more question, is there any technique to clean the newly created database in mysql or I have to manually remove or combine similar rows?
George Jonsson 18-Nov-15 3:55am    
KISS = Keep It Simple Stupid :-)

You can write and execute an SQL script or two.
That should be pretty straight forward and if you do it in the Query editor in MySQL Workbench, you can see the results immediately.
Member 12147416 18-Nov-15 4:15am    
I am sorry to bother you, being new in mysql, it's a bit tough for me!, so the cleaning process is like optimize the table? I am using phpmyadmin, if not how does look like a cleaning SQL script?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900