UXML – Tutorial TUTORIAL RUN-DOWN ..........................................................................................................................1 PREPARATION .......................................................................................................................................1 ANALYZING A RELATIONAL DATABASE ................................................................................................4 EXPORTING XML DOCUMENTS ............................................................................................................9 IMPORTING AN XML DOCUMENT TO RELATIONAL DATABASE ..........................................................19 UXML can be used as a powerful but yet user-friendly end user tools for manipulating relational database and XML documents. This tutorial will guide you step by step for some commonly used features of the software and you can therefore have a better understanding of the software. Tutorial Run-down This tutorial is divided into various parts as the following. 1. Preparation – You will start the software with your computer and prepare the necessary relational database for subsequent operations. 2. Analyzing a relational database – With the prepared relation database prepared in the previous step, you will be provided the instructions for analyzing it for its schema and the underlying data semantics. 3. Exporting XML documents – You will be provided the instructions for exporting data stored in the tables of the relational database as XML documents. 4. Importing XML document to relational database – With the exported XML documents, you will be provided the instructions for importing them in a target relational database. Preparation Objectives • To start UXML • To prepare the necessary relational database for subsequent operations Instruction Starting UXML For any Windows platform, you can use Windows Explorer to locate the directory, C:\Program Files\UXML\, and execute the UXML.bat in it. For UNIX clone (and Linux), you have to consult the system administrator for the installation path of the software. Then, execute the UXML.sh script that is stored in the installation path. Starting the demonstration relational database Once UXML is started, select Database > Start Demo Database from the system menu of software as shown in Figure 1, and a message dialog will appear telling you the settings for using such demonstration database as shown in Figure 2. Figure 1 – Starting the Demo Database Figure 2 –The dialog showing the details of using the demo database Creating a New Project UXML uses a project to maintain all details of a relational database. As such, you have to firstly create a project so that you can subsequently analyze it. 1. To create a new project, you can either select File > New Project from the system toolbar, or click New Project on the system toolbar. Then enter the project name are shown in Figure 3 and click “Next” button. Project Name: demo Figure 3 – The first step of the New project dialog for getting a project name 2. For the second step of the New project dialog, you can set the database server type and its name as Figure 4 and click “Next” button to go to next step. Server type: HSQLDB Database name: demo Figure 4 – The second step of the New project dialog for specifying database settings 3. For the third step of the New project dialog, you can provide a combination of user name and password for user authentication while connecting to relational database. After you set it then click “Next” button. User name: sa Password: (leave it blank) Figure 5 – The third step of the New project dialog for specifying login settings 4. For the forth step of the New project dialog, the detailed information of the database connection is shown. You can verify the correctness of the information provided. Then click Finish button. Figure 6 – The forth step of the New project dialog for confirming project settings If everything runs successfully, you should get a dialog message showing the progress details. Click Close button. Analyzing a relational database Objective • To explore table structures and their records in relational database. Instructions 1. In the Project Explorer pane, right click a particular table under TABLE node are shown in Figure 7 and select Show Table Structure, a Table Structure Viewer window will appear in the working pane of UXML showing the structure of the selected table which all table properties are shown in Table1. Figure 7 - Showing a particular table structure For example, the figure below shows a table structure of the table “ASSET”. Table 1 - The structure of particular table 2. In the Project Explorer pane, you can right click a particular table under TABLE are shown in Figure 8 and select Show All Records, a window will appear in the working pane of UXML showing all records of the selected table are shown in Figure 9. Figure 8 - Showing all records of particular table action For example, the figure below shows all records of the table “EMPLOYEE”. Figure 9 - Showing table records 3. In the Project Explorer pane, there is a new item “demo” that denotes the source database. Double click it to expand. Figure 10 - The main window of UXML Right click the TABLE item in the Project Explorer pane and select Determine Data Semantics option in the popup menu. Figure 11 - Determining Data Semantics You should get the following dialog. Figure 12 - Selecting data semantic approach Two approaches of determining data semantics are provided. Select the Candidate data semantics, then click Finish button. A dialog popup appears ask for your confirmation to discover data semantics. Click Yes button to start the re-engineering process. Figure 13 - Confirming to determine data semantic Then a message dialog appears showing that the data semantics have been discovered automatically. Click OK button. Figure 14 - Discovering data semantics 4. In the Project Explorer pane, right click the Data Semantics item and select Show EER graph option to show the Extended Entity Relationship (EER) diagram. Figure 15 - Showing EER diagram 5. Two different ER diagrams are provided. It was a Simple and Extended ER Diagram. Simple ER Diagram does not show aggregation relations which will be shown as usual many-to-many relation, whereas aggregation relations will be identified in the Extend ER diagram. On the other hand, Simple diagram provides several different layouts of the diagram. You selected the “Simple ER Diagram”. Figure 16 - Specifying the ER diagram mode 6. Simple ER diagram with Self Organizing Map Layout was shown. You can select other layouts which were Spring, Circle, Kamada Kawai and Fruchterman Reingold. The Self Organizing Map is referred. Figure 17 - Showing the generated ER diagram 7. You can save the diagram as an Image in machine. Click “Save Image” button. The diagram was prompt out for assigning the filename (Demo) of diagram. Figure 18 - Saving the generated ER diagram Figure 19 - Showing the image of saved ER diagram The image file is shown in Figure 19 that you selected before. Exporting XML Documents Objective • To export the contents of relational database as XML documents. Instructions 1. In the Project Explorer pane, right click a particular table under TABLE node are shown in Figure 20 and select Export As XML, a wizard will appear in front of the working pane of UXML. Figure 20 - Exporting the content of particular table to XML document 2. In the step, two ways for setting of destination are provided which are shown in Figure 21. To specify database setting, you can select either Obtain settings from project or Enter new database settings for getting setting from an existing project or specifying new database settings right away. Select the Obtain settings from project (demo) and then click Next button. Figure 21 - Specifying database setting dialog 3. You could select the way to obtain records from the selected project or database which are shown in Figure 22. The upper option that you could get records based on data semantics. Another option allows you to specify a query to retrieve the records. For this case, you should select the option of Getting records based on data semantics. Figure 22 - Specifying the exporting approach 4. In the Select tables as top-most element dialog, you select “CRAFT” in the drop-down list box and leave the With related table(s) as child elements checkbox checked. Then click Next button. Figure 23 - Selecting table as top most element 5. In the Specify XML namespace dialog, use the default settings and then click Next button. Figure 24 - Specifying namespace setting 6. In the Specify XML structure and condition(s) dialog are shown in Figure 25, you select the “CRAFT” from the XML document structure pane. Under Table settings tab, select the checkbox of the Child Table “WORKORDER”. Then click Update button. Figure 25 - Specifying XML structure and condition dialog 7. Click on the Attribute settings tab, you can specify which attribute(s) to be exported. Leave the attributes EMP_ID and EMP_NAME checked. Unchecked the attribute “SKILL”. Change the Type of attribute “EMP_NAME” from Attribute to Element as shown in the following figure. Figure 26 - Specify the exporting attribute in XML document setting 8. Click on the field of the attribute “EMP_NAME”, a dialog appears allowing adding sub-attributes.” In the Attribute and Value fields, type “version” and “1” respectively. Then click OK button. Figure 27 - Adding other sub attributes in specific column 9. As Figure 28, you can select the “WORKORDER” from the XML document structure pane. Under Table settings tab, select all checkboxes of the Child Table “WORKORDER”. Click Update button. Then click Next button. Figure 28 - Specifying the exporting child tables which must have related records 10. As Figure 29, you can specify the XML document to be exported based on your previous selections. For the exported XML document, you can specify the schema. In the XML schema settings, select XML with external XSD and then click Next button. Figure 29 - Specifying the export destination Figure 30 - Processing dialog to operation export feature The system will generate the XML document and the corresponding XSD are shown in Figure 31 and Figure 32 respectively. Figure 31 - Showing the exported XML document Figure 32 - Showing the exported XSD document Export as XML – With advanced data semantics 1. In the Project Explorer pane, right click a particular table under TABLE node are shown in Figure 33 and select Export As XML, a wizard will appear in front of the working pane of UXML. Figure 33 - Exporting the content of particular table to XML document 2. In the step, select the Obtain settings from project and demo from the associated list and click Next button. Figure 34 - Specifying database setting dialog 3. You could select the way to obtain records from the selected project or database which are shown in Figure 35. The upper option that you could get records based on data semantics. Another option allows you to specify a query to retrieve the records. For this case, you should select the option of Getting records based on data semantics. Figure 35 - Specifying the exporting approach 4. In the Select tables as top-most element, you select “CRAFT” and leave the With related table(s) as child elements, With advanced semantics and With entire categorization relation checkboxes checked. Then click Next button. Figure 36 - Specifying table as top-most element 5. As Figure 37, it is allows user to input filtering criteria, enter the following constraint in the Condition(s) filed of the attribute EMP_ID: EMP007, EMP008. Then click Next button. Figure 37 - Specifying the condition(s) for retrieving the records 6. As Figure 38, leave the View the generated file(s) on screen checked, then click Next button. Figure 38 - Specifying the export destination 7. The Figure 39 shows the progress details. Click Close button to close the dialog. Figure 39 - Processing dialog to export XML document The system will generate the XML document; the corresponding Data Type Definition (DTD) and XML tree model for the required root entity are shown in Figure 40, Figure 41and Figure 42. Figure 40 - Showing the exported XML document Figure 41 - Showing the contents of exported DTD Figure 42 - Showing the DTD graph based on DTD contents Importing an XML Document to Relational Database Objective • To import the contents of XML documents into a relational database. Instructions 1. Select the demo project from the Project Explorer pane and select File > Export > As SQL from the system menu. For the Load settings from file step, click Next. 2. For the Specify database settings step, click Next. 3. The Select Table(s) to be exported step enables you to specify the tables to be exported. Select the table ASSET from the Outstanding table(s) to be exported list and click >>. 4. In order to create all tables that are related to the ASSET table, select ASSET from the Selected table(s) to be exported list and right-click it to show a popup menu. Select Select related table(s) option on it. 5. The Specify SQL statement options step, you can specify the options of the SQL statements to be exported. By default, all options are selected. Uncheck the options with foreign keys and Export table data. 6. The Specify the export destination step enables you to specify the file that stored the SQL statements. The default setting is a file named exported.sql stored in the default export directory. Select the option View the generated file(s) on screen option so that the contents of the exported file will be shown. Click Next. 7. For the Save settings to file step, click Finish. Then, the SQL Viewer window will appear that shows the contents of the exported file. 8. Select File > New Project from the system menu and the New Project dialog will appear. For the Specify a project name step, enter target in the Project name box as the project name of the project to be created. Click Next. 9. For the Specify the database settings step, specify the following settings: Server Type: HSQLDB Database: target and click Next. 10. For the Specify login settings, enter sa in the Username box and leave the Password box blank. Click Next. 11. The Confirm project settings step enables you to confirm the setting. Click Finish to create the project. 12. Select the project target from the Project Explorer. Then, select Database > SQL Commander from the system menu to show the SQL Commander window with a pane for the target database. 13. Click Load on the SQL Commander and a dialog appear for you to choose a SQL script file to be loaded. Select exported.sql that was just exported with the Open dialog. Click Open to close the dialog. 14. Click Execute on the SQL Commander window and a message dialog appears stating that the SQL statements were executed successfully. 15. Select the project target from the Project Explorer pane and select File > Refresh Project from the system menu. 16. Examine the project target in the Project Explorer by expanding it. You will find that the table ASSET and all its related tables are created. 17. Select the project demo and select File > Export > As XML from the system to show the Export table(s) as XML dialog. Click either Next or Finish on all step to export the table ASSET with related tables to the file ASSET.xml. 18. Select the project target and select File > Import from XML from the system menu to show the Import XML to database dialog. For the Load settings from file step, click Next. 19. For the Specify JDBC setting for target database step, click Next. 20. For the Specify approach for handling each transaction step, with the default option Auto Commit for each record click Next. 21. For the Please specify the option for batch ID generation step, click Next. 22. For the Specify a XML file for import step, click Browse... to show the Open dialog. Choose ASSET.xml and click Open to close the Open dialog and return to the Import XML to database dialog. Then, click Next. 23. For the Specify Password for XML step, click Next. 24. For the Specify Element as Table step, click Next. 25. For the Specify XML Relational Database Mapping step, click All Default to map the XML element types with the tables with the same name. Click Next. 26. For the Specify log file for the operation step, click Next. 27. For the Save settings to file step, click Finish. 28. The import operation is performed and you will be prompted with the result by either a message dialog stating that all elements are imported successfully or a dialog with a list of error messages. For our case, a dialog with a list of messages will be shown as the following.