DATAUML Design Tutorial 3-Model and database synchronization

Source: Internet
Author: User

In the previous section, we have built the data model, so how to synchronize the data model with the database? It is very simple to synchronize the model to the database, only the model can be bound to the database. DATAUML design currently supports and synchronizes Oracle with MS Server databases.
Model binding to the database here is no longer explained, do not understand please see a section of the content.
1, synchronization data table (model synchronization to the database)
Synchronization principle: ① first synchronization of the main table, after the same pace table. Create a new table if the table does not exist in the ② database, modify the table if the table exists.
Here we synchronize order: Purchase order, supplier information, purchase orders
1), select "Supplier Information" right-click to select "Synchronize data table (save to database)" 3-1, and then pop-up dialog box "after synchronizing to the datasheet is not undone, do you want to synchronize to the datasheet?" ", select" Yes ". Data tables are synchronized to the database. Figure 3-1

The following is a log of the synchronization data table
Supplier Information Form
[Supplier information]: start syncing to datasheet
[Supplier information]: CREATE TABLE "Suppliers" success
[Supplier Information]: Add Table "Suppliers" Comment succeeded
[Vendor information]: Create PRIMARY Key "Pk_suppliers (ID)" Succeeded
[Supplier Information]: Synchronize to data table end
Purchase order Form
[Purchase order]: Start syncing to data table
[Purchase order]: CREATE TABLE "PurchaseOrder" success
[Purchase order]: Add Table "PurchaseOrder" Comment succeeded
[Purchase order]: Add Field "ID" Comment succeeded
[Purchase order]: Add Field "Storagetype" Comment successful
[Purchase order]: Add Field "OrderID" Comment successful
[Purchase order]: Add Field "Agentsorderno" Comment successful
[Purchase order]: Add Field "Ordertime" Comment successful
[Purchase order]: Add Field "Supplierscode" Comment successful
[Purchase order]: Add Field "orderstate" Comment successful
[Purchase order]: Add Field "Buyer" Comment successful
[Purchase order]: Add Field "Operationtime" Comment successful
[Purchase order]: Add Field "Operationuser" Comment successful
[Purchase order]: Create PRIMARY Key "Pk_purchaseorder (ID)" Succeeded
[Purchase order]: Create Unique key "Uk_orderno (OrderID)" Success
[Purchase order]: Create foreign key "Fk_suppliers_purchaseorder (ID)->suppliers (ID);" Success
[Purchase order]: Synchronize to data table end
Purchase Schedule
[Purchase Order Details]: Synchronize to the end of the data table
[Purchase Order Details]: Start syncing to the datasheet
[Purchase Order Details]: CREATE TABLE "PurchaseOrderItem" success
[Purchase Order Details]: Add Table "PurchaseOrderItem" Note success
[Purchase Order Details]: Create PRIMARY Key "Pk_purchaseorderitem (ID)" Success
[Purchase Order Details]: Create FOREIGN key "Fk_order_item (OrderID)->purchaseorder (OrderID);" Success
[Purchase Order Details]: Synchronize to the end of the data table
After the synchronization is complete, the data model records the information that is bound to the data table.
You can use Plsql to see if a table has been created in the database. As followsFigure

the picture is the Purchase order table”

The key information for the "Purchase Order" chart

After the classes and data tables in the model are bound, select Clear synchronization information and check synchronization status in the right-click menu of the class to become available. 3-2


Figure 3-2the Check synchronization status menu is followed by a table name that describes the class and data table binding.
If you modify the properties of a class in the model, simply select the right-hand "synchronize data Table" menu for the class. DATAUML design automatically updates the data table structure with SQL statements.

2. Check the synchronization status
The following is an example of a "purchase order":
1), add a new field to the model
Add a field memo to the purchase order, then select the class, right-click the Check Sync Status menu, and the following prompt appears:
[Purchase order]: Start check
[Purchase order]: Field "Remark" does not exist in datasheet
[Purchase order]: Check End
Description The field does not exist in the data table remark
2), Model modify field properties
In Purchase order, modify the field "buyer" to a length of 51, the default value is gust, the note is "buyer notes", and then right-click to select the "Check sync Status" menu, the following prompt appears:
[Purchase order]: Start check
[Purchase order]: The length of the field "Buyer" in the datasheet is inconsistent with the field length of the model
[Purchase order]: The field "Buyer" Memo in the datasheet is inconsistent with the model comment
[Purchase order]: The default value of the field "Buyer" in the datasheet is inconsistent with the default value of the model
[Purchase order]: Field "Remark" does not exist in datasheet
[Purchase order]: Check End
3), model delete a field
Delete the agent order Number field in the purchase order, and then right-click to select the Check Sync Status menu with the following prompt:
[purchase order]: Start check
                     [purchase order]: The property does not exist in the model as " Agentsorderno "Field
                     [Purchase order]: The length of the field "Buyer" in the datasheet is inconsistent with the field length of the model
                     [Purchase order]: Data table field "Buyer" Notes are inconsistent with model notes
                     [Purchase order]: The default value of the field "Buyer" in the datasheet is inconsistent with the default value of the model
                     [Purchase order]: Field "Remark" is not present in the datasheet
                      [Purchase order]: Check End
4), add table unique key in model
In Purchase order, add a unique key name Uk_test, and then right-click to select theCheck sync statusmenu, the following prompt appears:
[Purchase order]: Start check
[Purchase order]: A field with a property of "Agentsorderno" does not exist in the model
[Purchase order]: The length of the field "Buyer" in the datasheet is inconsistent with the field length of the model
[Purchase order]: The field "Buyer" Memo in the datasheet is inconsistent with the model comment
[Purchase order]: The default value of the field "Buyer" in the datasheet is inconsistent with the default value of the model
[Purchase order]: Field "Remark" does not exist in datasheet
[Purchase order]: Data table Unique key information inconsistent with model unique key information
[Purchase order]: Check End
When you modify the "Purchase order" structure in the model, you do not have to modify the data table structure at the same time, in order for them to synchronize, you can use the "Synchronize data table" operation to complete the following:
With the modified class structure selected, click the right mouse button to select the Synchronize Datasheet menu and the following prompt appears:
[Purchase order]: Start syncing to data table
[Purchase order]: Update table field "Buyer" data type and length Nvarchar2 (51) Success
[Purchase order]: Update the memo "buyer Notes" for table field "Buyer" Success
[Purchase order]: Update table field "Buyer" Default value gust successful
[Purchase order]: Add Table field "Remark" succeeded
[Purchase order]: Table primary key: Pk_purchaseorder (ID)
[Purchase order]: Table Unique key: Uk_orderno (ORDERID);
[Purchase order]: Create unique key "Uk_test" success
[Purchase order]: The foreign key information for the table is: [PurchaseOrder (ID)->suppliers (ID)]
[Purchase order]: Data table column "Agentsorderno" does not match the model, using advanced actions to delete mismatched columns
The Synchronize data table action does not delete the columns in the datasheet, and you use the Synchronize Advanced Actions feature to delete the columns in the data table.
3, synchronous advanced operations
Synchronous Advanced Operations Delete columns in the data table, delete them regardless of data in the data table, and delete all foreign keys of the data table. such as 3-3


Figure 3-3

We still take the "purchase order" as an example, the previous action removed the "agent order Number" in the "Purchase order" structure, and the data table has the "Proxy order Number" column, then we can use advanced operations to complete it.
With the "Purchase order" selected, click on the "Synchronize Data Advanced Actions" submenu of the right mouse button to "Delete extra data columns" to indicate the following:
[Purchase order]: Synchronize to data table end
[Purchase order]: Delete data column "Agentsorderno" success
[Purchase order]: Delete data column complete
The data column "Agent order Number" of the "Purchase Order table" in the database is also deleted, and we can use the Check Sync status function to see if the model and data table are consistent.
4. Synchronization model (database synchronization to model)
When a class in a model is bound to a table in a database, if you don't know whether the class structure in the model is up-to-date and you want to use the table structure information in the database, you can synchronize the structure in the data table to the classes in the model.
The synchronization model is divided into two ways: Full synchronization and append synchronization. 3-4
① Full synchronization: The table structure in the database is the standard, completely updated to the model in the class structure. The model class and data table structure information are exactly the same at this point. If the class structure field in the model does not match the fields in the table in the database, the mismatched fields in the model class are automatically deleted.
② Append synchronization: Take the table structure in the database as the standard, completely update to the class structure in the model. At this point, the model class and data table structure information can be inconsistent, the structure of the model class information is greater than or equal to the data table structure information. If the class structure field in the model does not match the fields in the table in the database, the system does notdeleting fields that do not match in the model class will only update or add new information in an appended way.


Figure 3-4

Let's give an example.
1), delete the "Vendor information" class in the model.
2), add a new class to the model. 3-5


Figure 3-5

3), select the newly added class, right mouse button Select "With small model ..." in the submenu "Full Sync", a dialog will pop up, let you choose a table, 3-6, here we select the suppliers (Supplier information) table.


Figure 3-6

4), click "OK ", you can see the Synchronized data table structure information, 3-7


Figure 3-7

5. Clear the synchronization information
The classes in the model and the tables in the database are bound together, if you want to clear the binding information, select the classes in the model, and right-click to select "Clear synchronization Information".
Why do you want to have the "Clear sync Information" feature?
If the class in the model is bound to a table in the database, but the table in the database is deleted, and if you want to synchronize the model to the data table, you will be prompted to find the data table, you can use the "Clear synchronization information" function to clear the binding information, and then synchronize the model to the database when the system creates a new table.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.