UXML An XML Gateway ! " ! " #$ % &'% ()%* +#$ % &'&,%%%- For more information about UXML software product, please write or call Universal Data Warehousing Limited, Block B, 4/F, 15 Hongning Road, Kwun Tong, Kowloon Hong Kong Tel: (852) 8119 0835 Fax: (852) 2788 8614 The SOFTWARE and documentation are provided with RESTRICTED RIGHTS. Use, duplication, or disclosure by the Government is subject to restrictions as set forth in subdivision (c)(1)(ii) of The Rights in Technical Data and Computer Software clause at 52.227-7013. Contractor/manufacturer is UDW Ltd., Block B, 4/F, 15 Hongning Road, Kwun Tong, Kowloon, Hong Kong. General notice: Other product names mentioned herein are used for identification purposes only and may be trademarks of their respective companies. Windows is a trademark of Microsoft Corporation. UXML User’s Guide, Release 1.0 Copyright © 2005 by UDW Ltd. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of the publisher. 2 Universal Data Warehousing Limited has been dedicated in the researches and software developments in the area of relational database and various XML technologies. Since the establishment of the Company, various software applications have been released that facilitate the adoption of latest technologies in relational database and XML. With extensive experiences in software developments for relational database and XML technologies, we developed UXML as a comprehensive and user-friendly database and XML technology software utility. UXML can verify structures, constraints and data of the tables in relational databases and XML documents and provide you insightful information of the relational databases so that you can have a better understanding of the relational databases and the XML documents. Furthermore, UXML can provide you all necessary functionalities that you need to bridge the world of relational databases and XML technologies, such as exporting and importing XML document from and to a relational database with a few mouse clicks. Besides, UXML supports web services that enables you to send and receive XML documents between heterogeneous platforms through the Internet. UXML provides a user-friendly interface so that all options and features are accessible via system menus, toolbars and context sensitive pop-up menus that can be shown by right-mouse clicking at particular items or regions on the user interface. Besides, most operations are dialog driven and you are guided and you are provided the necessary data for performing particular operations. The UXML User’s Guide documents the graphical user interface of UXML. The operations performed by UXML are based on the theories, algorithms and methodologies that are the research results of our researchers. Besides, UXML concerns various data semantics among the tables and data in relational databases and Appendix A provides you the list of data semantics with detailed descriptions. Available versions UXML is developed with pure Java technologies and it can therefore be executed on various platforms provided that there is a compatible Java Runtime Environment (JRE) version 1.5 or higher. There are three versions of UXML, which are simplified, full and enterprise versions. Evaluation version – This version is a light version of the enterprise version that can connect to the embedded HSQLDB relational database only.. Simplified version – This is a complete version that can connect to all commercial relational database servers, but this version does not support web services for sending/receiving XML documents Full version – This version is also a complete version that is to be deployed by enterprises and customization services are provided. Compatibility As UXML is developed with pure Java technologies, it can be executed on most popular platforms that a compatible JRE with version 1.5 or newer exists, such as Microsoft Windows (98 Second Edition/NT/2000/XP), Solaris and Linux, which are officially support by Sun Microsystems. If you are using a platform other than the above three platforms, please contact the vendor of your hardware for the availability of a compatible JRE. i Serial Numbers Each copy of the enterprise version of UXML is associated with a serial number and such number is your identification number with UDW Ltd. You need to provide such serial number when you contact UDW Ltd. regarding support, payment and information enquiry. The serial number can be found on the CD of the software that comes with the box-set package if you purchase it via a retail store or the number is provided in the confirmation email if you download and purchase the enterprise version from our official web site. Customer Service Contact our Customer Service at (852) 8119 0835 if you have any questions regarding the shipment of the software to you or payment. Please provide us your serial number for identification purpose. End-user Trainings UDW Ltd. provides regular and on-demand end-user trainings. All training sessions are instructor led and feature hands-on workshops. For more information on end-user trainings, contact us at our Customer Service. Technical Support UXML Technical Support services registered customers of UXML only. Customers that are entitled to phone-support may contact Technical Support at (852)8119 8035. Be prepared to identify yourself and the serial number of your UXML copy. All registered customers are entitled to e-mail support and customer may send email to dbx@udw.com.hk regarding the usage, installation help and bug reporting. Lend Us Your Thoughts We value you comments. So send us a letter or e-mail and let us know about your experiences with UXML. We especially like to hear about new and interesting features that you may think UXML could provide that facilitate your day-to-day operations. Write to UDW Ltd., Universal Data Warehousing Limited, Block B, 4/F, 15 Hongning Road, Kwun Tong, Kowloon, Hong Kong. ii OVERVIEW OF UXML........................................................................................................................ 1 GETTING STARTED ............................................................................................................................... 2 INSTALLATION OF UXML.............................................................................................................. 15 SYSTEM REQUIREMENTS..................................................................................................................... 15 OTHER REQUIREMENTS ...................................................................................................................... 15 GETTING THE SOFTWARE UXML ....................................................................................................... 15 INSTALLING UXML ........................................................................................................................... 15 INSTALLING UXML WITH AN INSTALLATION SCRIPT FILE .................................................................. 21 STARTING UXML .............................................................................................................................. 22 INSTALLING SUPPLEMENTARY JDBC DRIVERS ................................................................................... 22 UNINSTALLING UXML ...................................................................................................................... 23 STARTING UXML FOR THE FIRST TIME .............................................................................................. 24 RELATIONAL DATABASE ANALYSIS ......................................................................................... 27 CREATING A NEW PROJECT ................................................................................................................. 27 STARTING EMBEDDED DEMONSTRATION DATABASE .......................................................................... 33 SAVING A PROJECT ............................................................................................................................. 33 REFRESHING THE META-DATA OF THE ASSOCIATED RELATIONAL DATABASE ..................................... 33 VIEWING THE STRUCTURE OF THE ASSOCIATED RELATIONAL DATABASE ........................................... 34 MANIPULATING THE ASSOCIATED DATABASE WITH SQL ................................................................... 36 DETERMINING DATA SEMANTICS ........................................................................................................ 38 VIEWING THE EXTENDED ENTITY-RELATIONSHIP (EER) DIAGRAM ................................................... 42 DATA EXPORT/IMPORT ................................................................................................................. 47 EXPORTING RELATIONAL DATABASE AS XML DOCUMENTS ............................................................... 47 VISUALIZING XML DOCUMENT WITH XML TREE MODEL ................................................................. 62 IMPORTING XML DOCUMENTS TO RELATIONAL DATABASE ............................................................... 63 DATA COMMUNICATION WITH WEB SERVICES.................................................................... 73 INTRODUCTION ................................................................................................................................... 73 STARTING A WEB SERVICES SERVER ................................................................................................... 75 STOPPING A WEB SERVICES SERVER.................................................................................................... 85 SENDING XML DOCUMENT VIA WEB SERVICES .................................................................................. 85 OPERATING SETTINGS................................................................................................................... 89 SAVING THE OPERATING SETTINGS ..................................................................................................... 89 LOADING THE OPERATION SETTINGS .................................................................................................. 90 DATA SEMANTICS............................................................................................................................ 91 ONE-TO-ONE RELATIONSHIP ............................................................................................................... 91 ONE-TO-MANY RELATIONSHIP ............................................................................................................ 92 MANY-TO-MANY RELATIONSHIP ........................................................................................................ 92 ISA (SUBTYPE) RELATIONSHIP ........................................................................................................... 93 DISJOINT GENERALIZATION ............................................................................................................... 94 OVERLAP GENERALIZATION ............................................................................................................... 95 CATEGORIZATION RELATIONSHIP ...................................................................................................... 95 AGGREGATION RELATIONSHIP ........................................................................................................... 96 TOTAL PARTICIPATION ....................................................................................................................... 97 PARTIAL PARTICIPATION .................................................................................................................... 98 WEAK ENTITY .................................................................................................................................... 98 iii N-ARY RELATIONSHIP ........................................................................................................................ 99 iv UXML is a user-friendly software application that can be both an end-user tool and an enterprise strength server for end-to-end data communication with Extensible Markup Language (XML) documents. As an end-user tool, UXML enables you to analyze a relational database for determining the data semantics behind the table structures, constraints and data. In addition, UXML can visualize the determined data semantics as an Extended Entity Relation (EER) diagram. Documents in XML format is getting more and more popular and most software applications accept XML documents as the data source. UXML is a handy software application for you to create XML documents in various structures based on the contents of a relational database. UXML can visualize the structure of an XML document as an XML tree model diagram so that you do not have to study its clumsy schema. On the reverse direction, UXML can help you to store XML documents to any relational database based on the contents of XML documents with optional schema. Last but not least, UXML enables you to specify the criteria so that only data satisfying them are exported to the created XML documents and you can subsequently send it right away with the web services based data communication functions. Figure 1.1 visualizes the functionalities of UXML as an end-user tool. EER RDBMS UXML XML XML Tree Model Figure 1.1 As an end-user tool, UXML can bridge RDBMS with EER, XML and XML Tree Model UXML can also be a mission critical enterprise level software application for end-to-end transmission of XML documents via web services. Since web services has been a de facto enabling technology for distributed computing, you can make use of UXML to send XML documents to other platforms or systems with web services through the Internet. Besides, UXML can communicate with a native XML database, such as Tamino server by Software AG, so that the received and transmitted XML documents are stored natively, so that you can 1 2 Overview of UXML use X-Query, the native query language for XML, to retrieve XML documents from it. Figure 1.2 depicts the usage of UXML in an enterprise environment. UXML RDBMS XML DB Figure 1.2 XML XML Internet/ Intranet UXML RDBMS XML DB Using UXML as an enterprise tool for real-time communication with XML documents As illustrated in Figure 1.2, the XML documents exported from relational databases can be sent to other software applications over the Internet or Intranet, which can be any web services enabled server processes or another up and running UXML. This is also a typical scenario of business-to-business (B2B) applications through the Internet, and various departments of an enterprise can also make use of UXML for synchronizing the business data among them. Getting Started This section presents you a walk-through of UXML for its core features so that you can have a rough idea what UXML can do for you. The detailed descriptions and usages of the features can be found in their respective chapters. Starting UXML The way of starting UXML depends on the platform on which you install UXML. (If you have not installed UXML, you can download an evaluation copy from the official web site and following the instruction of Chapter 2 for the installation instructions.) The installation process will create a target directory for the software and there exist two script files, UXML.sh and UXML.bat, which are the start up scripts for UNIX clone (or Linux) and Windows platforms respectively. Execute the suitable script on your machine to start UXML and its GUI will be shown. If you are running the evaluation version of the software, a notification dialog will appear stating that the software is for evaluation purposes only and the number of days before its expiry. Figure 1.3 The information dialog that is shown by the evaluation version UXML User’s Guide 3 System menu System toolbar Project explorer pane Property viewer pane Working pane Server message pane Figure 1.4 The various parts of the GUI of UXML With respect to the GUI shown in Figure 1.4, the various parts and their functions are presented in Table 1.1. Table 1.1 The various parts of the GUI and their functionalities Component System menu System toolbar Project explorer pane Property viewer pane Working pane Description Its menu items can be selected for performing a particular operation. If a particular operation is not applicable at the moment, the corresponding menu item is disabled and its caption is dimmed. Whenever a new window appear in the Working pane, a new menu item will be added to the Window menu of the System menu, which provide you a quick way to switch to a particular window by selecting its corresponding menu item from the menu. When the software is started, there is no window in the Working pane and hence the Window menu contains no menu item. Each icon on the System toolbar can be used to start a frequently used operation or feature of the software. If you want to have a description of the operation that is associated with the icon, place the mouse pointer on it for a while, a descriptive tool-tip will appear. In UXML, a project associates with a relational database and all projects that you create in UXML appear in the Project explorer pane in a tree structure. By expanding a node in the tree, you can explore the tables that are determined from the relational database and further information of the tables. Whenever you select an item in the Project explorer pane, such as a project, table, column, key and so on, the Property viewer pane shows its property. While you are using the software, new windows will be shown in Working pane, such as SQL Commander, XML Viewer, whenever necessary. All these windows appear in the Woring pane, a corresponding menu item will be created under the Window menu of the System menu. If you want to switch to another window in the Working pane, other than minimizing the current top-most window in the Working pane and select another window, you can select its corresponding menu item under the Window system menu. When the software is started, the Working pane contains no windows, and the Window system menu is therefore initially blanked. 4 Overview of UXML Server message pane It shows the server messages whenever UXML receives XML document by up and running embedded web services server. Initially, no XML receiver processes are started and such pane is therefore initially hidden. The four panes, Project explorer pane, Property Viewer pane, Working pane and Server message pane of UXML can be resized by dragging the boundary in between two panes with your mouse and the boundaries are highlighted in Figure 1.5. Figure 1.5 The boundaries to be used for resizing the panes Table 1.2 illustrates the icons that can be found in the System toolbar with descriptions. Table 1.2 The icons on the System toolbar and their functionalities New Project Create a new project that associates with a relational database. Save Project Save the currently selected project to your computer drive. Refresh Project Refresh the project by retrieving the database structure from the associated relational database again. If data semantics have been determined for the current database structure, these data semantics will be removed. Export as XML Export contents of tables in a relational database as an XML document. Import XML Import an XML document to a relational database. Start XML Receiver Start a XML Receiver, which is a web services server, to accept XML document sent via web services. Help Access to the help materials that comes with the software. Creating a new project Before performing any operation on a relational database, you have to create a project for the relational database so that its database structure is firstly retrieved. To create a new project, UXML User’s Guide 5 click New Project from the System toolbar or select File > New Project from the System menu, and the New project dialog as shown in Figure 1.6 appears. User entry pane Help message pane Figure 1.6 The New project dialog for creating a new project Being a user-friendly software application, UXML uses dialogs to guide you step by step for getting the necessary input for performing the operations, such as the New project dialog as shown in Figure 1.6. The dialog is partitioned into the User entry pane and the Help message pane. Depending on the data to be collected, GUI components, such as text boxes, tables and drop-down lists, are shown in the User entry pane for collecting the necessary user entries. At the same time, context sensitive help message will appear in the Help message pane providing you the descriptions and usages of the GUI components shown in the User entry pane. After you provide the data that are required by the dialog and click Next, UXML will validate the data you provided and proceed to the next step, if any. If there is any problem in the data you provide, a dialog with error messages and recommendations will appear so that you can rectify your entries. If the data provided are valid, you will proceed to the next step and another set of GUI components will appear for getting another set of entries. If such step is the last step of the dialog, the title of the Next button will be changed to be Finish. For detail operations of the New project dialog, please refer to Chapter 2. After a new project is created successfully, a new item is shown in the Project explorer pane as shown in Figure 1.7 and you can further manipulate and analyze the associated relational database. Figure 1.7 The Project explorer pane of UXML with a new project demo Showing structure and records of a table Once a project is created, you can expand the project item in the Project explorer pane by clicking the handle at the left of the project name or double clicking the project name for the TABLE item and subsequently the list of tables that exist in the associated relational database. By further expanding a table item, you can view its definition or structure, such as 6 Overview of UXML the list of its columns, keys and foreign keys in the Project explorer pane as shown in Figure 1.8. Figure 1.8 The structure of a table shown in the Project explorer pane Besides, you can choose Tools > Database Utilities > Show Table Structure while you are selecting a particular table in the Project explorer pane, and a Table Structure Viewer window will appear in the Working pane as shown in Figure 1.9. Figure 1.9 The Table Structure Viewer showing the structure of a table Besides showing the structure a table, you can select Tools > Database Utilities > Show All Records to retrieve all records from the currently selected table, and a SQL Commander window will appear that looks like the one as shown in Figure 1.10. UXML User’s Guide 7 Figure 1.10 The SQL Commander window showing the records obtained from the relational database The SQL Commander window enables you to enter SQL statements to be sent a relational database for executions. Showing all records in the table is actually one of the possible ways to use such window. Discovering data semantics from a project Each project is associated with a relational database and you can determine data semantics from a project, which is actually from the associated relational database. With these discovered data semantics, UXML can further construct an extended entity-relation (EER) diagram. To determine data semantics from the associated relational database of a project, select the desired project from which data semantics are to be discovered, and select Tools > Discover Data Semantics, and the Discover Data Semantics dialog will appear as shown in Figure 1.11. Figure 1.11 The Discover Data Semantics dialog 8 Overview of UXML Complete the Discover Data Semantic dialog by choosing a discovery mode and clicking Finish, UXML will determine data semantics from the associated relational database and a new item is shown in the Project explorer pane as shown in Figure 1.12. Figure 1.12 The Project explorer pane of UXML with data semantics discovered for a project By expanding the Data Semantics item in the Project explorer pane, you can further access to the discovered data semantics that are classified under different data semantic names. Clicking a particular data semantic and UXML will show its details in the Property viewer pane as illustrated in Figure 1.13. Figure 1.13 Property Viewer pane with details for a particular data semantic Showing Extended Entity-Relation (EER) diagram Even the Property Viewer pane can provide the details of each data semantic, it would be even better to have a complete picture of the relationships among the tables in the associated relational database, and Extended Entity-Relation (EER) diagram is an elegant facility for this purpose. UXML User’s Guide 9 To view an EER diagram for the tables in a relational database, select the corresponding project and select Tools > Show EER Diagram and the EER diagram will be constructed and shown in the Working pane of UXML, such as the one shown in Figure 1.14. Figure 1.14 An EER diagram shown in the Working pane The EER Diagram window that appears in the Working pane is further partitioned into two panes, the miniature and the actual EER diagram that are on the left pane and the right pane respectively. If the associated relational database defines plenty of tables and hence a complicated EER diagram is constructed, the entire EER diagram is most probably unable to be entirely shown on the screen and you can therefore view a particular region of it. To view another region of the EER diagram, you can click the miniature pane at the desire location with your mouse pointer or use the scrollbars on the right and at the bottom of the actual EER diagram pane. UXML enables you to generate hardcopies of the EER diagram by selecting File > Print… and the native Print dialog of the platform will be shown enabling you to select the printer to be print and the settings. Exporting and importing XML documents UXML is not only a relational database visualizing and analysis tool, but also a handy software utility for data conversion between relational databases and between relational databases and XML technologies. UXML can generate XML documents based on the contents stored in relational databases. In the reverse direction, it can import XML documents to relational databases. To export an XML document from a relational database, you have to firstly select a table as the top-most elements (other than the root element) to be exported. UXML will determine the 10 Overview of UXML related records in other tables to be exported as sub-elements in the XML document. Besides, you can set the criteria with which the records to be exported must satisfy. Furthermore, UXML can generate the corresponding schemas, either a Document Type Definition (DTD) or an XML Schema, which can validate the generated XML documents. The entire export operation is carried out by using a user friendly dialog that guides you the operations step by step, and the options of schema generation are shown in Figure 1.15. Figure 1.15 The possible options for the schema to be generated with a exported XML document The exported XML documents are shown in the XML Viewer window in the Working pane of UXML, as shown in Figure 1.16. Figure 1.16 The XML Viewer window showing the content of the exported XML document UXML User’s Guide 11 The two buttons Previous and Next at the bottom of the XML Viewer window are enabled if necessary, for you to view large XML documents. On the other way round, UXML enables you to import XML documents to relational databases. Given an XML document, UXML will verify the existences of the corresponding tables in the desired destination relational database. For example, while importing an XML document to a relational database, the Import XML to database dialog appear and one of the step of operating the dialog as shown in Figure 1.17 enables you to map XML elements with corresponding tables in that relational database. Figure 1.17 The Import XML to database dialog enabling the user to specify the table to be performed on different XML element types stored in the XML document Different XML element types stored in the XML document are to be stored in the corresponding tables in the destination relational database, and the corresponding tables can be created, if they do not currently exist. Then, the Import XML to database dialog provides you the options to specify the table structures to be created as shown in Figure 1.18. 12 Overview of UXML Figure 1.18 The dialog enabling the user to specify the table structure to be created for a particular XML element type Complete the Import XML to database dialog, UXML will process the specified XML document and store the XML elements in the XML document to their corresponding tables. If there is any error in importing the XML document, UXML will show the error messages so that you carry out remedial actions. For further details of the options and operations of exporting and importing XML document, please refer to Chapter 4. Sending and receiving XML documents via web services XML document format is currently the de facto standard of documents to be transmitted through the Internet. On the other hand, web services is becoming the nature choice of communication standard in the world of XML technologies. In view of this, UXML supports sending and receiving XML document via web services, so that a user can use UXML to send exported XML document to another user who is using a web services enabled software application, such as another copy of UXML. In case the recipient user is using UXML, the received UXML can be stored seamlessly into his/her relational database. On the XML Viewer pane, there is a Send button that enables you to send the current XML document to a web services enabled software that can be specified by the Send XML via HTTP dialog as shown in Figure 1.19. UXML User’s Guide Figure 1.19 The dialog for sending XML document via web services (or HTTP) If you are the recipient who is going to receive XML documents, you can start an XML Receiver so that UXML will wait for the arrival of the XML documents and the Server Message pane will be shown below the Working pane as shown in Figure 1.20 for you to inspect the statuses of the processes XML documents. Figure 1.20 UXML with Server Messages pane 13 14 Overview of UXML Storing and loading of operation settings UXML enables you to store the operation settings so that you can reuse the settings repeatedly, especially those operations that need to take plenty of user entries. As such, you can specify all the necessary settings once and you can then perform the same operation with a few mouse clicks. For those operations that support setting storage and retrieval, the first step and the last step of the dialog are for loading and storing settings respectively as shown in Figure 1.21 and Figure 1.22. Figure 1.21 The dialog for loading operation settings Figure 1.22 The dialog for saving the operation settings For further details of the operations mentioned in this chapter, please refer to the corresponding sections in the following chapters. Thanks to the Java technologies, UXML is a true cross-platform software application that can be installed on various platforms with a compatible Java Runtime (JRE) version 1.5 or higher. In this chapter, you will be guided the procedure of installing UXML on your machine. System requirements UXML is written in pure Java technology that requires a compatible Java Runtime (JRE) version 1.5 or higher for run-time execution. For hardware requirements, a machine with 256M is required and the hardware requirements for x86 platforms, including Microsoft Windows (NT/2000/XP), UNIX clone or Linux, are: • Pentium III 800MHz or higher (Pentium 4 2.0GHz preferable) • 256M memory (512M preferable) • Hard drive with at least 20M free space • Network interface for connecting remote database servers Other requirements Besides software and hardware requirements, you mostly have to obtain access privileges from database administrators for accessing the database servers, especially in an enterprise environment. For performing analysis related operations, access with read-only privilege is sufficient, whereas update privilege is required for operations that need to update the data stored in the database servers. On UNIX clone platforms, if you are going to use UXML for receiving XML documents with network points less than 1024, you mostly need the super-user (or root) privilege so that UXML can listen to those ports. Getting the software UXML UXML is available on CD-ROM and can be downloaded from our official web site, http://www.udw.com.hk/, via the Internet. If you cannot obtain the software via the Internet, please contact our customer services for the details of getting the software CD-ROM. Installing UXML UXML is packaged with a user friendly software installation module with a graphical user interface (GUI) so that you are guided the every step during the installation. Therefore, although the ways of starting the installation module for different platforms are different, the installation details are roughly the same once it is started. However, a prerequisite is that your computer must be installed with a JRE version 1.5 or higher and the executable java (or 15 16 Installation of UXML java.exe for Microsoft Windows platforms) can be located according to the search path on your platform, such as specified by the environment variable PATH on Microsoft Windows platforms and UNIX clone. If your computer is not yet installed with a compatible JRE and you are installing UXML with an installation CD, you can find various Java Development Kit (JDK) installation files for common platforms in the directory /jdk of the installation CD. Otherwise, you can download a JRE (or JDK) version 1.5 or newer from the official web site of Java technology, http://java.sun.com/ or the official web site of your hardware vendors. Starting the installation for Microsoft Windows (NT/2000/XP) If you install UXML from a CD, inserting the CD to the CD-ROM reader of your computer mostly will start the installation process automatically and the installation dialog as shown in Figure 2.1 will appear. Figure 2.1 The installation dialog for UXML In case the auto-start feature of your computer is disabled, you can browse at the root directory of the CD-ROM reader of your computer and double-clicking the file setup.bat, as shown in Figure 2.2 and the installation dialog as shown in Figure 2.1 will appear as well. Figure 2.2 The setup.bat file stored in the root directory of the installation CD Once the installation dialog appears, you can follow the instructions provided on the dialog to complete the installation. Further details of the installation will be presented later in this chapter. UXML User’s Guide 17 If you still failed to start the installation process and the installation dialog is not shown, it is highly possibly that neither JRE nor JDK is installed properly on your machine, or the executable java.exe cannot be located according to the environment variable PATH. To verify whether the executable can be located automatically by the computer, you can start a Command Prompt, such as by selecting Start > Accessories > Command Prompt for Microsoft Windows XP or start a shell to the UNIX clone machine, and enter the following command, java -version and message that looks like the following should appear in the Command Prmopt: java version "1.5.0_05" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05) Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing) Otherwise, it confirmed that neither JRE nor JDK is not properly installed and set up, and you should download a JRE (or JDK) version 1.5 from the official web site of Java or use a JDK installation file that stored on the installation CD for installing a compatible JRE. Starting the installation on other platforms To install UXML on other platforms, such as UNIX clone and Linux, you can firstly access to the root directory of the installation CD and execute the command, java -jar install.jar and the same installation dialog as shown in Figure 2.1 will appear. The installation process Once the installation process is started and the installation dialog as shown in Figure 2.1 appears, you can follow the installation provided on the dialog to continue the installation procedure. During the entire installation process, there are two buttons, Previous, Next and Quit appear at the bottom of the dialog for returning to the previous step, proceeding to the next step and terminating the installation process immediately respectively. Click Next on the dialog as shown in Figure 2.1, the dialog as shown in Figure 2.3 will appear. 18 Figure 2.3 Installation of UXML The second step of the installation that provides you the detail information about UXML The dialog as shown in Figure 2.3 provides you further information about the software UXML before the software is actually installed to your machine. Read the information and if you feel comfortable with the software, click Next to proceed to the next step and the dialog as shown in Figure 2.4 will appear. Figure 2.4 The third step of the installation for you to confirms you accept the license agreement The dialog as shown in Figure 2.4 shows you the license agreement that you have to comply with if you are going to install and use UXML, and the Next button on the dialog is initially disabled unless you select the option I accept the terms of the license agreement. Select the option and click Next to proceed to the next step as shown in Figure 2.5, or you have no choice but to click Quit to abandon the installation process. UXML User’s Guide Figure 2.5 19 The fourth step of the installation for you to provide an installation path A proposed installation path is provided on the dialog and you can choose your own one. Click Next and the installation path will be verified. You will be prompted with a dialog that looks like the one in Figure 2.6 to confirm whether to create the directory if it does not currently exist, and the dialog as shown in Figure 2.7 appears. Figure 2.6 The confirmation dialog to confirm the creation of the installation path You have to make sure that you have the necessary privileges to access and create files for the specified installation path, or the installation will fail. If you want to enable all users of the machine to use a same copy of UXML, please make sure that the installation path can be accessed by those users of the machine. 20 Figure 2.7 Installation of UXML The fifth step of the installation showing the files to be installed to your computer You should keep all options shown in Figure 2.7 selected to ensure all necessary files are installed and click Next to start installing the files to the specified installation path. The dialog will show you the progress throughout the entire installation of the files. When all files are installed, the dialog will become the one as shown in Figure 2.8. Figure 2.8 The sixth step of the installation after all files are installed Click Next to proceed to the next step for the status of the installation as shown in Figure 2.9. UXML User’s Guide Figure 2.9 21 The final step of the installation showing the installation has completed and some supplementary options On the dialog shown in Figure 2.9, you can click Generate an automatic installation script to prepare a script so that UXML can be installed again using the script without any user intervention. It is especially useful if you are going to install UXML to more than one computer with the same configurations. Click Generate an automatic installation script and a Save dialog will appear, such as the one shown in Figure 2.10 on Windows platforms, for you to specify the directory and the file name of the installation script. Figure 2.10 The Save dialog for specifying the installation script Specify the directory and the file name of the installation script with the Save dialog and click Save to save the installation script file and close the dialog. Click Done on the installation dialog to close it and UXML is installed successfully. Installing UXML with an installation script file To install UXML with an installation script that you prepared by a previous installation, you can start a Command Prompt or a terminal for Windows platforms and UNIX clone (or Linux) respectively and enter the following command: java -jar install.jar <installation script> For example, on a Windows platform, if the installation script is stored on a floppy drive A named install.xml and the UXML installation file on a CD-ROM that can be accessed via drive D. The command will be, 22 Installation of UXML java -jar D:\install.jar A:\install.xml The installation will start and complete without user intervention. Under some special circumstances, it is necessary for you to install UXML to a machine that does not equipped with a graphical user interface, such as Microsoft Windows or X-Windows for UNIX clone (and Linux). For example, a server machine executes UXML as a background process for receiving XML documents. If so, you can install UXML to another machine with similar configuration but with a windows system. During the installation process, you create the installation script and you can then install UXML to the target machine with the installation script. Starting UXML Once UXML is installed successfully, you can start using it. In the installation path that you specified, there are two start-up scripts, UXML.bat and UXML.sh, for Microsoft Windows platforms (NT/2000/XP) and UNIX clone (and Linux) respectively. Execute the corresponding script file on your computer and UXML will be started. If you are executing an evaluation version of UXML, a message dialog will appear telling you the number of days before the expiry date. A possible way to execute the start-up script is to start a Command Prompt or a terminal for Windows platforms and UNIX clone (and Linux) respectively and execute the start-up script from within it. Then, you can follow the instructions provided in the subsequence chapters to use UXML. If you are executing UXML on a Microsoft Windows platform (NT/2000/XP), you can create a short-cut to the start-up script, UXML.bat, so that you can start it conveniently. To create a short-cut for the script, UXML.bat, on the desktop browse the directory of your installation path and dragging the UXML.bat file to the desktop while you are pressing the right mouse button. When you release the mouse button, a pop-up menu appears and you can select Create shortcuts Here and a new icon named Shortcut to UXML will be created on the desktop for the script file. You may further change the name of the icon to be just UXML for convenience. Installing supplementary JDBC drivers UXML uses JDBC to connect various relational database servers, and the JDBC drivers for most common relational database servers are installed during the installation process, except some JDBC drivers are the restricted by the corresponding relational database vendors, such as the native JDBC driver for Oracle is the property of Oracle that cannot be re-distributed with UXML. In case you are going to connect a relational database that UXML does not support, you are running UXML on a Windows platform and the relational database can be accessed via Microsoft Open Database Connectivity (ODBC), you can set up a Data Source on your machine and connect that relational database server via ODBC. However, some features may be restricted if you are connecting to a relational database via ODBC. UXML User’s Guide 23 Another scenario is that you can select a particular database server in UXML but you are prompted that the necessary driver does not exist, such as the case for Oracle, it is because the necessary JDBC driver is the property of the database vendor and it is not possible for UXML to redistribute the binary. In such case, you must install the necessary JDBC driver manually. You mostly can find the necessary JDBC driver from the installation package of that relational database or can be obtained from the official web site of the relational database vendor. Then, you can place the necessary file, such as the classes12.jar file for Oracle, in the directory lib under the installation path. Restart UXML and you can connect to that relational database. As an example, if the installation path of UXML is C:\Program Files\UXML, the directory to which the JDBC driver file to be placed is C:\Program Files\UXML\lib. Similarly, if UXML is installed to the /home/user/UXML on UNIX clone (or Linux), you should place the JDBC driver file to the directory, /home/user/UXML/lib. If the name of your relational database cannot be found in the option, UXML cannot connect it for instance. Please contact our customer service so that we could provide you the necessary files and instructions for connecting your specific relational database. Uninstalling UXML During the installation of UXML, a uninstall module named uninstaller.jar is stored in the Uninstaller directory under the installation path. On Windows platforms, browse at such directory as shown in Figure 2.11 and double-clicking the uninstaller icon to start the un-installation process as shown in Figure 2.12. Figure 2.11 The Uninstaller directory with the uninstaller icon on a Windows platform Figure 2.12 The un-installation dialog An alternative approach is you can start the uninstaller module manually via Command Prompt on Windows platforms or a terminal on UNIX clone (or Linux). The commands to start the uninstaller module are, 24 Installation of UXML java -jar <installation path>\Uninstaller\uninstaller.jar or java -jar <installation path>/Uninstaller/uninstaller.jar for Microsoft Windows platforms and UNIX clone (or Linux) respectively. The uninstallation dialog as shown in Figure 2.12 will appear no matter you start the module via a windows user interface or with a command. Select Force the deletion of <installation path> on the dialog will remove the files in the installation path one by one. Otherwise, the software is uninstalled by deleting the directories in the installation path on directory basis, that is, an entire directory one at a time. In general, no matter you select the option or not, the software UXML will be removed successfully. If you start the installation module via a windows user interface, such as the Windows Explorer on Microsoft Windows platform by selecting Start > Accessories > Windows Explorer, and browse at the <installation path>\Uninstaller to start the uninstaller.jar to uninstall the software, the directory <installation path>\Uninstaller will not be removed because the Windows Explorer process is using the directory and hence cannot be removed. For a clean un-installation with all directories and files removed, use the former command line approach that starts the uninstaller.jar explicitly while the current directory is out of the installation path can remove all directories and files. Starting UXML for the first time Every time UXML starts, it searches for a license file for verifying the software is properly registered. Otherwise, especially the first time when you start UXML, you will be prompted with a message dialog, and a UXML Registration dialog as shown in Figure 2.13 and Figure 2.14 respectively. Figure 2.13 The dialog to be shown if you start UXML without a license file UXML User’s Guide 25 Figure 2.14 The UXML Registration dialog Click OK on the dialog as shown in Figure 2.13 and you can start registering UXML with the UXML Registration dialog. In the UXML Registration dialog, you have to provide your name, company name and email address that are required for the registration. An email with registration data is to be sent to UDW Ltd for generating the necessary license file, and you are therefore necessary to provide the host name or IP address of the SMTP server to be used for sending the registration email. After you have provided all these four data, click Send registration email and a registration email will be sent and you have to wait for the arrival of reply email that will attach the necessary license file. In general, a reply email will be arrived at mailbox of the email address that you provided above in less than 10 minutes. Upon the arrival of the email, you can continue to install the license file to your UXML. There are three ways to install the license file. 1. You can use your usual email software, no matter web-based or not, to check for the reply email. The subject of the reply email is “License file for UXML by UDW Ltd” and there is an attached file that is the necessary license file. Then, you can firstly save the attached file to your computer drive. With UXML, you can enter the path of the license file that you saved in the License File box or you can locate the file by clicking the Browse… button. Afterwards, click Install to install the license file to your UXML. 2. UXML can check your mailbox for getting and installing the necessary license file automatically. You can firstly click the Check E-mail tab and the dialog will become the one as shown in Figure 2.15. Then, you can provide the username, password and the POP3 server for the email address that you specified during the registration. Finally, click Check Mail and UXML will connect to your POP3 server for checking the reply email and installing the license file. 3. The final approach of installing the license file is that you can copy and paste the values in the attached license file to UXML so that the license file is created on the fly. You can click the Paste Values tab and the dialog will become the one as shown in Figure 2.16. Then, you can copy and paste the license code, start code and expiry date that are obtained from the contents of the license file. Finally, you can click Save License Data to create the license file. 26 Installation of UXML Figure 2.15 The entries for getting license file directly from the mailbox Figure 2.16 The entries for copying the values from the attached file for creating the license file No matter which approach you use to install the license file, click Finish and UXML will reverify the license file. If the license file is valid, the UXML Registration dialog will disappear and you can start using UXML. Otherwise, the UXML Registration dialog will retain until either the license file is installed properly or you click Cancel to close and terminate the registration process. UXML provides powerful analytical features that can help you to analyze relational databases regarding their structures, constraints and the data semantics among the tables. A typical sequence of analyzing a relational database is, • creating a new project that associates with the desired relational database, • inspecting the structures and contents of the tables of the relational database, • determining the underlying data semantics among the tables, and • visualizing the data semantics with a Extended Entity-Relationship diagram (EER diagram) Creating a new project UXML uses a project to associate with a particular relational database and to maintain all the data obtained from it. Therefore, before you can perform any analytical operation on the relational database, it is necessary for you to create a project for the desired relational database. To create a new project, you can either, • select File > New Project from the system menu, or • click New Project on the system toolbar and the New project dialog as shown in Figure 3.1 will appear. 27 28 Figure 3.1 Relational database analysis The first step of the New project dialog for getting a project name As a reminder, most dialogs used by UXML are partitioned into two panes, the User Entry pane and the Description pane at the top and at the bottom of the dialog respectively. You provide your entry with the GUI components, such as text field, drop-down list and so on appear in the User Entry pane, whereas the Description pane provides you context sensitive description or help message. The first step of the New project dialog prompts you for the name of the project, and you can enter the project name in the Project name box that composes of alphanumeric characters only. To proceed to the next step, click Next and the second step of the dialog will appear as shown in Figure 3.2. Figure 3.2 The second step of the New project dialog for getting the necessary information for connecting the relational database UXML User’s Guide 29 For the second step of the New project dialog, the Server type list shows you all relational database products that your copy of UXML can connect. Click the down-arrow at the right of the Server type list or click the Server type list with your mouse pointer, a drop-down list will appear showing you all relational database products that can be connected, and you can select the corresponding one for your desired relational database. Most relational database servers are accessible remotely via the network, or in general the Internet. Therefore, the typical parameters for connecting a remote relational database are, • Host/IP Address. The host name or the IP (Internet Protocol) address of the machine that hosts the relational database server process. You can provide a host name that can be resolved to an IP address or an IP address in the format of four numeric values (ranged from 0 to 255) delimited with periods, such as 101.102.103.104. If you are using UXML to access the relational database that is hosted on the same machine, you can enter either the IP address of the machine, host name localhost or the default loop-back IP address 127.0.0.1. • Port number. Another necessary parameter for starting a network connection, other than the host name or IP address, is the port number to which the relational database server is listening. Every relational database product has its own default network port number for handling the incoming network connections. You can provide the port number of the desired relational database server or leave it blank and UXML will connect to the server with the default port number of that relational database product. • Database. A relational database server mostly can support more than one database at the same time, which is identified by a database name. You can provide the database name in the Database box to which your project is referring to. After you provide all the above entries, click Next and UXML will verify the host name or IP address and the port number immediately. In case any entry is invalid, a dialog with error message will appear so that you can determine the necessary changes in the entries for retrying the connection. Otherwise, the next step of the dialog as shown in Figure 3.3 will appear. On Windows platforms, UXML (full version and enterprise version) supports connecting a relational database via Microsoft Open Database Connectivity (ODBC), and you can select “ODBC” from the Server type list and enter the Data Source Name (DSN) in the Database box and UXML will connect to the desired relational database via ODBC. Please be reminded that connecting a relational database via ODBC may prevent UXML from getting complete database structure from the underlying relational database specified by the DSN, and it is therefore always preferable to connect relational database servers via their corresponding JDBC drivers. If you are running UXML on a machine with proper DNS settings, you can provide either host name or IP address, as the DNS server will be inquired for resolving the IP address from the specified host name. Otherwise, you should provide an IP address explicitly so that no IP address resolution is required, especially if you are connecting a remote database server on your Local Area Network (LAN) and no DNS server is available for you LAN. 30 Relational database analysis The valid range of port number is from 1 to 65535. If you know the desired relational database is using the default port number, you can leave it blank. Otherwise, you have to specify the port number of the desired relational database server. Figure 3.3 The third step of the New Project dialog for login information For the third step of the New project dialog, you are prompted to enter the user name and password for logging on the relational database. Please consult the database administrator of the desired relational database server for the combination of the user name and password. Both User name and Password are optional that you can leave it blank if no user name and/or no password is/are required. Click Next and the fourth step, which is the last step of the dialog will appear as shown in Figure 3.4. In general, most relational database servers maintain the combinations of user name and password and authenticate the user themselves. However, some relational database servers support other authentication methods, such as the Windows authentication approach by Microsoft SQL Server, and the JDBC driver that comes with UXML does not support such authentication method. In case it is necessary for you to connect a relational database server using authentication method that is not supported by UXML, you have to find the necessary JDBC driver, such as from a third-party company that supports that authentication method and contact our customer service for a customization service so that you are provided the necessary files for making use of your own JDBC driver from within UXML. UXML User’s Guide Figure 3.4 31 The last step of the New project dialog for confirming the user entry provided The dialog as shown in Figure 3.4 provides you all the information to be used for connecting with the relational database server. If necessary, you can click Back to a previous step for amending the user entries you provided. If you are satisfied with the information shown, click Finish and UXML will actually connect to the desired relational database. While UXML is connecting to the desired relational database and getting the database structure from it, a Progress dialog will appear telling you the progress as shown in Figure 3.5. Figure 3.5 The Progress dialog that appears while UXML is accessing the relational database for getting the database structures information If there is any error in accessing the relational database or getting database structures information, a dialog with error message will appear telling you the cause of the failure, such as the one shown in Figure 3.6. Figure 3.6 A sample dialog with error message if UXML fails to access a relational database The message shown in the dialog that is similar to the one as shown in Figure 3.6 provides you some insight the way to resolve the problem. In case you still have no idea of the cause of the problem, please contact our technical support with the message shown in the dialog so that we can provide you the necessary technical supports. 32 Relational database analysis As most relational database servers are accessed remotely via the network, such as Intranet and Internet, there may be many network devices on the way between your machine running UXML (the client machine) and the one hosting the relational database server (the server machine). As such, there are plenty of possibilities that a connection to the remote relational database server fails to set up. The following is a list of some typical causes. • The user entries, especially the host name/IP address and the port number are incorrect. If you are providing a host name, you should make sure your client machine can resolve the host name to an IP address. If you provide an IP address, you have to make sure such IP address is valid and can be reached with your client machine. • If you are running UXML on a client machine equipped with kind of firewall software that prevents UXML (or in general a JRE) from connecting to a remote machine, you can disable the firewall software temporarily and connect to the desired relational database with UXML again. If UXML succeeds to connect to the desired relational database, you can add JRE to the unblocked software list of your firewall software so that UXML can start a connection even the firewall software is running. • On the server machine, you have to make sure the port number to which the relational database is listening matches the one you provided in the Port number box. Furthermore, there is no firewall like software running on the server machine that blocks the incoming network connections to the port. You can disable the firewall like software on the server machine temporary to see whether it is the cause of the failure in starting the network connection. If so, unblock the port that your relational database is listening with the firewall software. • There are many network devices, such as network routers, on the way from your client machine to the server machine. You have to confirm with your network administrator to ensure network connections to the desired port number of the desired machine are enabled or permitted on all involved network devices. If UXML can successfully connect to the relational database and obtain the database structures, a new project with your specified name will appear in the Project Explorer pane as shown in Figure 3.7 so that you can further manipulate the project and the associated relational database. Figure 3.7 The Project Explorer pane showing a newly created project UXML User’s Guide 33 Starting embedded demonstration database If you do not have your own relational database but you want to experience with the features of UXML, there is a built-in relational database that can be started from within UXML. The tables defined in such demonstration database exhibit all data semantics so that you can have a better understanding of them. To start such demonstration database, select Tools > Database Utilities > Start Demo Database, and you will be prompted with a dialog as shown in Figure 3.8. Figure 3.8 The dialog stating the embedded relational database is started with the information of the necessary connection settings Now, you can connect to such database with the settings: Server type: HSQLDB Database name: demo User name: sa such as in dialogs as shown in Figure 3.2 and Figure 3.3 while you are creating a new project. Saving a project You can save the information maintained by a project to your computer drive so that it is not necessary for you to retrieve the structure of the associated database again in the future. Furthermore, most operations can obtain database connection settings from a project, and it is therefore highly preferable to save a project so that you do not have to specify the settings again. To save a project, select File > Save Project or click Save Project on the system toolbar. If there are unsaved projects or updated project and you terminate UXML, you will be prompted with a dialog for confirming you are terminating the software without saving the changes. Another scenario that you need to save a project is that you determine data semantics again for a project, and the determined data semantics will overwrite the original ones then you have to save the project again so that the changes in the data semantics are kept on your computer drive that can be reused in the future. If you terminate UXML without saving the projects that you create or amend (such as with updated data semantics to be discussed later in this chapter), the created project and the changes to the amended project will not be shown when you start UXML next time. Refreshing the meta-data of the associated relational database If the associated relational database of a project is updated, such as new tables are created or table structures are changed, you can refresh the project so that UXML obtains database structure again from the associated relational database and the information maintained by the project is updated. To refresh a project, select File > Refresh Project from system menu or click Refresh Project on the system toolbar. 34 Relational database analysis If data semantics for the project and hence the associated relational database were determined, refreshing a project will remove the determined data semantics from the project because some data semantics may no longer be valid. Further details of determining data semantics will be provided later in this chapter. Viewing the structure of the associated relational database In the Project Explorer pane, the items are arranged in the following hierarchy, • Project Name o Database Structure Table Type • Table o User Columns Individual Column Definition o Indices Primary Key / Candidate Key o Foreign Keys Individual Foreign Key o Data Semantics Data Semantic Type • Individual Data Semantics You can double click an item or click the handle at the left of an item to expand it to view its sub-items. Whenever you select a project, table, column, primary key/candidate key, individual data semantics, all available properties of the selected item will be shown in the Property Viewer pane. For example, Figure 3.9 shows that a column is selected and its properties are shown in the Property Viewer pane. Figure 3.9 A column is selected and all its available properties are shown in the Property Viewer pane Using the Table Structure Viewer window The Property Viewer pane can only show the properties of an item one at a time, which is inconvenient for you to inspect the properties of a few related items, such as the column definitions of a particular table. Instead, you can select Tools > Database Utilities > Show Table Structure from the system menu or right-mouse click a particular table and select UXML User’s Guide 35 Show Table Structure on the pop-up menu appears, and a Table Structure Viewer window will appear in the Working pane of UXML showing the structure of the selected table. For example, Figure 3.10 shows the Table Structure Viewer window showing the structure of a table. Figure 3.10 The four pages of the Table Structure Viewer window showing the structure of a table ASSET of project demo Table Structure Viewer window can show the structures of one than one table. You can use the tab at the top of the window to select the desired table for viewing its structure. For example, in Figure 3.10, the tab demo – ASSET indicates structure of the table ASSET of project demo is currently shown. The Table Structure Viewer window uses four pages to show the structure of a table, which are: • Columns page shows the definitions of the columns (or fields) of the table and each column definition contains the following seven columns: o Primary Key column indicates the primary key columns of the table and the primary key field contains YES in the cell. o Name column shows the table column name. o Type column shows the data type of the column. o Size column shows the table column size. o Decimal Digits column shows the number of digit for the fractional part of a numeric type column. For non-numeric columns, the cells are all zeroes. o Nullable column indicates whether the column is null-able or not. The value YES and NO denotes the table column can be NULL or cannot be NULL respectively. o Default Value column shows the default value of the table column, which is used when a new record is inserted to the table without specifying the value for such table column. 36 Relational database analysis • • • Foreign Keys page shows the foreign key(s) defined for the table and each row represents a foreign key definition with the following three columns: o Foreign Column Name column shows the list of table column names of this table used as the foreign key. o Primary Table Name column shows the primary table addressed by this foreign key. o Primary Column Name column shows the list of table column names of the primary key of the primary table. Indices page shows other indices defined for the table, including primary key and usual candidate indices. Each row represents either a primary key or candidate key with the following five columns: o Name column shows the index name, which is the name provided when the index was created explicitly, or a system generated one if the index was created implicitly. o Type column shows the index type specified by the relational database server which is relational database server product specific. o Column Name column shows the list of the names of the table columns involved in the index. o Order column shows the sorting order of the index, either Ascending or Descending. o Unique column shows whether the index is unique or non-unique. For a unique index, it restricts the values in the involved table columns in the table must be unique. Otherwise, the values in the involved table columns in the table can be duplicated. SQL DDL Statements page shows the Data Definition Language (DDL) statements in Structured Query Language (SQL) that can be used to create such table structure. You can click Close on the Table Structure Viewer window to close the currently viewing table structure. Manipulating the associated database with SQL You can manipulate the associated relational database of a project directly with SQL statements and you can therefore use UXML as a front-end user interface of your relational database server. The SQL Commander window of UXML enables you to manipulate the associated relational database of a particular project and UXML can be used as a front-end user interface of your relational database server. You can start it by selecting Tools > Database Utilities > SQL Commander and the SQL Commander window as shown in Figure 3.11 will appear. UXML User’s Guide 37 Operation buttons SQL statement input area Result output area Figure 3.11 The SQL Commander window The SQL Commander window can contain more than one page and each page is associated with a particular project and hence the associated relational database. The tab name of the page is in the format of, <Project Name> (<Page Number>). For example, the tab name, demo (1), indicates that the page corresponds to the project “demo” (and hence its associated relational database) and the page number is 1. The window can be partitioned into three parts, Operation buttons, SQL statement input area and Result output area. The Operation buttons part contains six buttons and their functions are: • Execute – Send the SQL statement entered in the SQL statement input area to the associated database of the specified project as identified by the tab name. • Save – Save the content of the SQL statement input area to a file so that you can read it and execute it in the future. • Open – Open a file so that its contents are shown in the SQL statement input area that can be further executed by the associated relational database. • New – Create one more page for the same project and hence the same associated relational database. As such, you can have more than one input area to enter the SQL statements at the same time for the same relational database. • Close – Close the current page of the SQL Command window. The SQL statement input area enables you to enter any SQL statements, such as those SELECT, INSERT, UPDATE, DELETE statements or Data Definition Language (DDL) statement that are to be sent to the corresponding relational database. After you have entered SQL statement(s) in the text area, you can click Execute to send the statement(s) to the relational database for actual execution. If the SQL statement to be executed by the corresponding relational database is an SQL SELECT statement, records are obtained from the relational database and are to be shown in the Result output area. The number of records shown depends on the query result, but UXML will show first 2000 records for each query in order not to use up all computer resources, especially memory. The number of columns to be shown depends on the SQL statement. If necessary, you may have to adjust the column width manually by dragging the mouse pointer on the boundary between two column headings. 38 Relational database analysis The SQL statements are to be executed by the corresponding relational database with the database user name that you provided for the project. As some operations can only be executed if the database user possesses particular access privileges, you must ensure the database user for accessing the relational database possesses the necessary privileges to execute the SQL statements you enter in the SQL statement input area. Otherwise, executing the statement will fail and you will be prompted with a dialog containing the details of the error. Some relational databases (such as Microsoft SQL Server) accept an optional statement terminator character, such as a semi-colon (;), and may support executing a sequence of SQL statements that are delimited with statement terminator characters. On the other hand, some relational databases (such as Oracle) do not accept any statement terminator character and hence can execute a SQL statement for each execution. You should ensure the SQL statements you enter into the SQL statement input area are valid with respect to the relational database server that is to execute them. If you are uncertain the syntax of the dialect of the SQL for your relational database server, please consult its documentation. Showing all records of a table You can start the SQL Commander window for a particular project (and hence the associated relational database) and show the records from a table by executing a simple SQL SELECT statement. UXML provides you another handy approach to do so by either selecting Tools > Database Utilities > Show All Records or right-mouse click a particular table in the Project Explorer pane and select Show All Records from the pop-up menu. Then, a new page will be shown in the SQL Commander window showing the records of the table and only the first 2000 records are shown if there are more than 2000 records in the table. Determining data semantics Data semantics are referring to the underlying relationships behind the tables and hence their records. In order to have a better understanding of a relational database or to verify the relational database, it is valuable to determine the data semantics from the associated relational database of a project. The data semantics that UXML can determine are, one-to-one, one-to-many, many-to-many, n-ary, aggregation, weak-entity, is-a, generalization and categorization. For further details of these data semantics, please refer to Appendix A. To determine the data semantics from the associated relational database of a project, select Tools > Determine Data Semantics or right-mouse click a project name and select Determine Data Semantics from the pop-up menu. Then, a dialog as shown in Figure 3.12 will appear. UXML User’s Guide 39 Figure 3.12 The Determine data semantics dialog for choosing the determination mode There are two options of the determination modes provided on the Determine data semantics dialog as shown in Figure 3.12, which are: • Original database design – Data semantics are determined based on table structures without considering the contents of the tables. As such, only one-to-many, n-ary, aggregation, weak-entity, is-a and generalization relationships can be determined. • Candidate data semantics – Data semantics are determined based on both table structures and their records. As a result, it is a more complete determination approach that can determine all data semantics mentioned above. Comparing the two determination modes, the one-to-one and categorization relationships cannot be determined without considering the records of the tables, as they may not be enforced with database structures or constraints. Besides, as Candidate data semantics approach needs to access the contents of the tables, the time required for the determination is longer than that of the Original database design, especially if the table sizes are huge. Select the desired determination mode on the dialog as shown in Figure 3.12 and click Finish, UXML will start determining the data semantics from the associated database of the project. Upon the completion of the determination, a confirmation dialog as shown in Figure 3.13 appears. Figure 3.13 The confirmation dialog that appears upon the completion of the determination Click OK on the confirmation dialog to close the confirmation dialog and the Determine data semantics dialog. Then, you will find that the project is refreshed with a new item Data Semantics under the project name and you can further expand the Data Semantics item to 40 Relational database analysis view the data semantic types determined, and the Project explorer pane looks like the one as shown in Figure 3.14. Figure 3.14 The project with a new Data Semantics sub-item that subsequently contains other sub-items for different data semantic types By further expanding the data semantic types, you can explore individual data semantic. Select a data semantic and its details are shown in the Property Viewer pane. Some data semantics are defined based on some primitive data semantics that you can further explore the details by expanding that data semantic. The presentations of the various data semantics are shown in Table 3.1. Table 3.1 The different ways of presenting the various data semantics in the Project Explorer pane One-to-one For each one-to-one relationship, a foreign table defines a foreign key that addresses the primary key of the primary table and the foreign key values in the foreign table are unique. The name is in the format <Primary Table> - <Foreign Table>. One-to-many Similar to the one-to-one relationship, a foreign table defines a foreign key that addresses the primary key of the primary table and the foreign key values in the foreign table can be duplicated. The name is in the format <Primary Table> <Foreign Table>. UXML User’s Guide 41 Many-to-many A many-to-many relationship is composed of two one-to-many relationships with the same table as the foreign table. Therefore, expanding a manyto-many relationship, there are two sub-items that are the two child one-to-many relationships. The format of a many-to-many relationship name is <First Foreign Table> - <Second Foreign Table> and the name of the child one-to-many relationships are the same as the usual one-tomany relationships. N-ary An n-ary relationship is similar to a many-tomany relationship but there are more than two child one-to-many relationships. The format of an n-ary relationship name is a list of Foreign Table delimited with hyphens. Weak entity Part of the primary key of a weak entity table is the foreign key that addresses the primary key of another table, which is known as the strong entity. The format of a weak entity relationship name is <Strong entity> - <Weak entity>. Is-a An is-a relationship involves a super-type and sub-type, where the entire primary key of the sub-type is also the foreign key that addresses the primary key of the super-type table. The format of a is-a relationship name is <Super-type table> - <Sub-type table>. Generalization A generalization relationship composes of more than one is-a relationship with the same supertype table. Therefore, expanding a generalization relationship shows the child is-a relationships. The format of a generalization relationship name is <Super-type table> (<List of sub-type tables delimited by commas>). 42 Relational database analysis Categorization A categorization relationship composes of more than one is-a relationship with the same sub-type table. Therefore, expanding a categorization relationship shows the child is-a relationships. The format of a categorization relationship name is (<List of super-type tables delimited by commas>) <Sub-type table>. Aggregation An aggregation relationship consists of a manyto-many or n-ary relationship and another one-toone or one-to-many relationship and the foreign table of the former relationship (many-to-many or n-ary) is the primary table of the latter relationship (one-to-one or one-to-many). The format of a aggregation relationship name is (<List of foreign tables of many-to-many or nary relationship>) - (<Foreign table>). The Project Explorer pane and the Property Viewer pane can be used to explore individual data semantic, but it is not possible to figure out the data semantics a table is involved. UXML can visualize the data semantics by an Extended Entity-Relationship (EER) diagram so that all data semantics determined for a relationship database are shown in the diagram and you can have an even better understanding of it. Viewing the Extended Entity-Relationship (EER) diagram Extended Entity-Relationship (EER) diagram is a standard approach for visualizing data semantics of a relational database. To show the EER diagram of the associated relational database of a project, you should firstly determine data semantics from the database and you can then select Tools > Show EER Diagram from the system menu or right-mouse click the Data Semantics item of a project and select Show EER Diagram from the pop-up menu. While UXML is constructing the EER diagram, the progress dialog as shown in Figure 3.15 will appear. Figure 3.15 The progress dialog shown while UXML is constructing the EER diagram The EER Diagram window will be shown upon the completion of its construction. Click Close on the Show EER Diagram dialog and you can access to the EER Diagram window as shown in Figure 3.16. UXML User’s Guide 43 Miniature pane EER diagram pane Viewing region Scroll bars Figure 3.16 The EER Diagram window shown in the Working pane of UXML Viewing an EER diagram Depends on the number of tables and relationships determined from the relational database, the EER diagram constructed may not be shown entirely within the EER diagram pane. In such case, you can use the scroll bars at the right and at the bottom of the EER diagram pane to view a particular region of the EER diagram. The Miniature pane of the EER Diagram window shows a reduced version of the EER diagram and the red rectangle on it indicates the Viewing region of the EER diagram is currently shown in the EER diagram pane. Besides, you can use the Miniature pane to view a particular region of the EER diagram by clicking the desired region in the Miniature pane. The scale of the EER diagram that is shown in the EER diagram pane can be changed by selecting View > Zoom from the system menu and then a menu item of either 100%, 125%, 150%, 175% or 200%. Viewing the EER diagram with a larger scale shows the text with a larger font size but less entities and relationships are to be shown in the EER diagram pane. On the other hand, viewing with a smaller scale can show more entities and relationships but the texts are in a smaller font size. You can rearrange the layout of the entities and the relationships on the EER diagram by dragging an entity or a relationship to a new position and all connection lines to such entity or relationship will be automatically adjusted. Clicking an entity or relationship on the EER diagram and the EER diagram pane will highlight the entity and all related relationships and entities by changing the colour of the boundaries and connection lines into blue. Furthermore, if you click an entity on the EER diagram, the corresponding table in the Project Explorer pane will be expanded and highlighted as well. If the EER diagram contains a lot of entities and relationship, it is difficult to find a particular entity or relationship on it. You can search for an entity or relationship by selecting View > Search entity from the system menu to show the Search Element dialog as shown in Figure 44 Relational database analysis 3.17. Then, you can enter the desired entity or relationship name in the Search Element box and click OK. If the entity or relationship can be found on the EER diagram, the EER diagram pane will scroll to show and highlight that item. Figure 3.17 The Search Element dialog Two entities may be directly related if there is a relationship between them, or they can be indirectly related if they are related via other entities and relationships. To show these possible paths of direct and indirect relationships, you can use the Cross Reference dialog as shown in Figure 3.18 that is shown by selecting View > Cross Reference from the system menu. Figure 3.18 The Cross Reference dialog On the Cross Reference dialog, select the two desired entities by Start Path and End Path and enter the maximum number of entities or relationship involved in the path (direct or indirect) between the two entities to be highlight in the Steps box. Click OK and all paths, including all involved entities and relationships, will be highlighted. Printing an EER diagram Other than viewing the EER diagram on a computer screen, you can obtain the hardcopies of the EER diagrams from UXML. You can firstly specify the page setup to be used for printing the diagram by selecting File > Page Setup… from the system menu and a platform specific Page Setup dialog as illustrated in Figure 3.19 will appear for you to specify the settings, such as paper size and margins. After updating the page setup, click OK to close the dialog. UXML User’s Guide Figure 3.19 The Page Setup dialogs for Windows XP and Linux respectively If you are satisfied with the current page setup, you can proceed to print the current EER diagram by selecting File > Print… and a Print dialog, which is also platform specific as illustrated in Figure 3.20, will appear for you to choose the desired printer and specify its settings. Figure 3.20 The Print dialog for Windows XP and Linux respectively Click OK on the Print dialog and the EER diagram will be printed to the desired printer. 45 46 Relational database analysis Other than getting hardcopies of the EER diagram, you may also need to obtain the softcopies of the EER diagrams for storage or communication electronically purposes. UXML does not natively support the generation of the softcopies, but you can make use of the services provided by the operating system to do so. A generic approach that is applicable to most platforms is: • Install a generic Postscript enabled printer to your machine • Print the EER diagram with such generic Postscript enabled printer with the option like Print to file. The contents of the file generated by printing the EER diagram in this way are in the Postscript language that can be viewed by any Postscript viewer, such as Ghostscript, Ghostview and GSview1. Besides, there is software that you can obtain from the Internet to further convert such file into other image formats, such as Portable Document Format (PDF). For example, on some UNIX clone and Linux platforms, you can use the command gs2pdf to convert the generated Postscript file into a PDF file. For Windows platforms, there is software (such as a freeware named CutePDF Writer2) that can set up a virtual printer to your computer so that you can print the EER diagram with such printer to generate the corresponding PDF file right away. 1 The official website of Ghostscript, Ghostview and GSview is http://www.cs.wisc.edu/~ghost/. CutePDF Writer is a product of Acro Software Inc. and can be obtained from the website, http://www.cutepdf.com/products/CutePDF/writer.asp. 2 % !" #$" In real world enterprise environments, there are plenty of scenarios that there is a necessity of exporting and importing database from and to a relational database. For example, • various departments of a company are running their own software applications and some data that are maintained by these software applications have to be shared among them, and data replications and/or synchronizations are therefore required; • business parties are sending business data among them for business operations, such as trading, order placing and so on, and the data are mostly in XML format; • it is necessary to backup the databases of a company in a generic way, especially if they are of different relational database server products; • the database of a relational database server is to be migrated to a different relational database server product; • an XML document is required to be composed based on the contents of a relational database that is to be attached with an e-mail to be sent. UXML provides you comprehensive features for exporting contents of relational databases as XML documents and importing the contents of XML documents to relational databases, so that you can use it as a handy data conversion software utility. Exporting relational database as XML documents To export an XML document from a relational database, you can • select File > Export > As XML… from the system menu, • click Export XML on system toolbar, or • right-mouse click a table and select Export as XML from the pop-up menu and the Export table(s) as XML dialog will appear as shown in Figure 4.1. 47 48 Figure 4.1 Data Export/Import The first step of the Export table(s) as XML dialog for specifying the setting file to be loaded and reused As the operation settings of exporting a table as an XML document can be stored in your computer drive, the first step of the Export table(s) as XML dialog enables you to load an existing setting file for the operation. If you want to use a new set of settings for the operation, keep the default option Specify new settings or select it and click Next to proceed to the next step as shown in Figure 4.2. Figure 4.2 The second step of the Export table(s) as XML dialog for specifying the source relational database You can use the second step of the Export table(s) as XML dialog for specifying the settings of the source relational database from which the XML document is to be exported. The dialog is divided into two regions, the Source of settings and Database settings regions. If you are going to use the settings from an existing project, you can select the Obtain settings from project option and select the desired project from the list at the right of the option and its UXML User’s Guide 49 settings are to be shown in the Database settings region of the dialog. Otherwise, you can select the Enter new database settings option and the user entries in the Database settings region are enabled for you to specify the settings. The usages of the options are the same as those for specifying the settings of the associated relational database while you are creating a new project. If you are satisfied with the entries, click Next to proceed to the next step of the dialog as shown in Figure 4.4. Figure 4.3 The third step of the Export table(s) as XML dialog for specifying whether XML document is to be exported based on data semantics or a user-defined query The third step of the Export table(s) as XML enables you to select on the of two possible approaches for exporting an XML documents by UXML, which are based on data semantics and based on a user-defined query. Select Getting records based on data semantics and you can subsequently select a top-most table and hence its related tables from which records are obtained to be exported to the XML document and hence the corresponding nested XML document structure. On the other hand, if you select Getting records by specifying a query, you can subsequently specify a user-defined query from which records are obtained to be exported to the XML document. Select either one of the two options and click Next, you will be prompted the corresponding step of the dialog. For the option Getting records based on data semantics, the next step to be shown is the one as shown in Figure 4.4. 50 Data Export/Import Basically, there are three different approaches of exporting XML documents that are supported by UXML. They are, • Exporting XML document based on a user-defined query – This approach enables you to define a query that can obtain some data from the relational database, and capability of the query is only restricted by the corresponding relational database only. Therefore, it is the most powerful approach among all. However, as you can only specify one query and all records can only be exported as the XML elements under the root element of the XML document, it can export simple XML document based on complicated SQL query. • Exporting XML document based on data semantics – This approach provides you a handy way to export data from a table and its related tables based on the data semantics, and the structure of the XML document can be nested for identifying the relationships among the different tables (and hence the XML elements). It is especially useful if you are going to export complicated XML documents with structure that is similar to the table schema of the relational database. A typical usage of this approach is to export XML documents for data replication for homo- or heterogeneous relational databases. The expected structure of the XML document to be exported Figure 4.4 The step of the Export table(s) as XML dialog for selecting the top most table to be exported and the export mode The step of the Export table(s) as XML dialog as shown in Figure 4.4 enables you to select the table to be exported as the topmost elements (other than the root element) in the XML document to be exported and you can do so by selecting it from the Table as topmost element list at the top of the dialog. If you start the operation while a table is selected, that table will be selected in the Table as topmost element list. At any time, the dialog will show you the expected structure (the nested structure of the XML elements) of the XML document to be exported. There are three options on the dialog as shown in Figure 4.4 and their usages are: UXML User’s Guide 51 • With related table(s) as child elements – if such option is selected, related tables (and subsequently their related tables) of the topmost table are exported as well. Otherwise, only the contents of the topmost table are to be exported to the XML document. By default, the topmost table is exported with all related (directly and indirectly) tables. If you change this option, the structure of the XML document to be exported will be refreshed and the expected structure will be updated accordingly as illustrated in Figure 4.5. • With advanced data semantics – Such option is enabled only if the option With related table(s) as child elements is selected. If such option is selected, tables are considered to be related to the topmost table if there are direct or indirect (via other tables) relationships between the topmost table and them with respect to all data semantics. Besides, extra attributes will be created for maintaining the data semantics among the tables. Otherwise (if such option is unselected), related tables are those defines a foreign key that addresses the topmost table directly or addresses another table that is related to the topmost table indirectly. • With entire categorization relation – Such option is enabled only if you selected the With advanced data semantics. If the topmost table is a super-type of a categorization relational, all other super-types of the categorization relationship are to be exported to the XML document as well. Otherwise, only the sub-type of the topmost table is considered to be the related table with respect to the categorization relationship. As such, if the topmost table does not the super-type of a categorization relationship, the expected XML structure is identical no matter the option is selected or not. Figure 4.5 The step of the Export table(s) as XML dialog if the With related table(s) as child elements is un-selected 52 Data Export/Import If the relational database from which you are going to export XML documents possesses data semantics including one-to-one, one-to-many, weak-entity, is-a and generalization only, the data stored in the exported XML document with and without advanced data semantics (that is the option With Advanced Data Semantics option is selected or unselected respectively) are the same. You should always refer to the expected structure of the XML document to be exported to see whether it fulfils you requirements. Please be noticed that the XML document exported with advanced data semantic will create synthetic ID/IDREF(S) attributes if necessary for maintaining the data semantics among the defining XML elements, whereas the without advanced data semantic approach does not. The with and without advanced data semantics approaches are using different mechanisms for exporting XML documents. For the with advanced data semantics approach, it keeps on querying the relational database by constructing necessary SQL statements that involve a table at one time only. Therefore, all relational database products should support such approach. On the other hand, the without advanced data semantics approach constructs a single SQL statement for querying all necessary data and the SQL statement may be optimized by the relational database and hence a faster performance. However, as the SQL statement is quite complicated, some relational database products may not be supported those constructed SQL statements. Exporting XML documents with advanced data semantics If you select the with advanced data semantics approach by selecting the With advanced data semantics option in the third step of the dialog as shown in Figure 4.4 and click Next, you will proceed to the fourth step of the dialog as shown in Figure 4.6 and UXML enables you to filter the records to be exported to the XML document by specifying the criteria the records in the tables must fulfil. Otherwise, the dialog as shown in Figure 4.16 will appear. UXML User’s Guide 53 The criteria for the selected table The expected structure of the XML document Figure 4.6 The step of the Export table(s) as XML dialog for specifying the criteria the records in the table(s) must fulfill so that they are exported to the XML document The dialog as shown in Figure 4.6 is mainly divided into two regions, the XML document structure region for the expected structure of the XML document for you to select a table on the left and the Condition(s) for table [<Table Name>] region for specifying the criteria for the selected table on the right. If all records in the involved tables are to be exported, you can simply click Next to proceed to the last step of the Export table(s) as XML dialog. Otherwise, you can follow the following steps in setting the criteria for the involved table. 1. Select a table from the XML document structure region on the dialog by clicking the desired table, and you may need to scroll the XML document structure with the scroll bars. 2. The Condition(s) for table [<Table Name>] region will show a table with two columns, the Column Name column and the Conditions column respectively and it will refresh whenever you select a different table from the XML document structure region. The Column Name column shows all table columns defined for the selected table and the Conditions column shows the conditions for a particular column. For example, for the dialog as shown in Figure 4.6, the table ASSET is selected from the XML document structure region and the four columns of the table is shown in the Condition(s) for table [ASSET] region. As illustrated, there are no conditions specified for the table. You can specify the conditions to the table by entering an expression in the Conditions column for the row of the desired table column. The supported expression is in the format. <Literal>, <Operator> <Literal> and <Literal>-<Literal> for exact match of a value, simple comparison with a given value and an inclusive range of the specified values respectively. The possible <Operator> can be <, <=, >, >= and <> (for not equal). A record is to be exported if all its columns fulfil the conditions specified for the corresponding columns. Besides, you can specify a list of such expressions, which adhere to the above format, and are delimited by comma(s) and a record is exported if it fulfils either one of the sub expressions. 3. If conditions are specified for the selected table, a pattern (?) is appended to the table name so that you can easily identify them. On the other hand, if the conditions for a table are cleared, the suffix (?) that was appended to the table name will be removed. 54 Data Export/Import 4. You can repeat the above steps to set the conditions for other tables. When you are satisfied with the conditions set, you can click Next to proceed to the next step of the dialog. Figure 4.7 A condition is specified to the EQUIP_ID column of the table ASSET and the name of the table ASSET is suffixed with (?) The following is a list sample conditions that can be set to be a condition. 5 Records with exact column values 5 will be exported. 1-10 Records with column values from 1 to 10 inclusive will be exported. >100 Records with column values greater than 100 will be exported. 1,3,5-10,>12 Records with column values 1, 3, 5 to 10 inclusive or greater than 12 will be exported. The next step of the dialog as shown in Figure 4.16 is for you to specify the schema to be exported. If you are exporting the XML document with advanced data semantics that you specified in the third step of the dialog (as shown in Figure 4.4), a schema file in Document Type Definition (DTD) format will be generated as well and no schema settings can be changed. Exporting XML documents without advanced data semantics If you specify you are going to export an XML document without advanced data semantics, click Next and you will be prompted with the subsequent steps for customizing the ways of exporting the XML document. Click Next in the third step of the dialog as shown in Figure 4.4, the dialog will become the one as shown in Figure 4.8 for you to specify the namespace to be used in the XML document to be exported. UXML User’s Guide Figure 4.8 55 The dialog for specifying the namespaces to be used in the XML document In the dialog as shown in Figure 4.8, if the elements in the XML document to be exported need namespaces, select the option Supports XML namespace and you can then specify the namespaces for the XML document. You can provide the default namespace URI (Universal Resource Identifier) in the Default Namespace box so that all elements in the XML document are considered to be in such URI. In addition, you can specify a list of namespace prefixes with the corresponding namespace names (URI’s) so that the prefixes can be used for specifying the XML elements to be generated. When you are satisfied with the options on the dialog, click Next to proceed to the next step of the dialog as shown in Figure 4.9. Figure 4.9 The dialog for specifying the export settings for individual tables 56 Data Export/Import To specify the settings for a table, you firstly select it in the XML document structure pane in the dialog and the options on its right will be enabled for you to specify the settings. • The option Export this table indicates whether such table is to be exported. All tables, by default, are to be exported. If you unselect the option for a table, the table and all its related tables, which are the sub-elements of the elements for this table in the XML document, are not to be exported. • The Element name box shows the default element name for the table, which is the name of the table with all spaces replaced with underscore characters (_). You can use such box to change the element name for such table. If XML namespaces have been defined in the previous step, the Namespace prefix box is enabled for you to enter a namespace prefix that must be pre-defined. • The Must have related records in the following child table(s) shows the child tables of the current table and you can use this list to specify the child tables so that a record in the current table is to be exported provided that it has related records in the specified child tables. If you update any setting of the above, click Update to update the settings. Click the Attribute settings tab, the dialog will become the one as shown in Figure 4.10. Figure 4.10 The dialog for specifying the attribute settings for the selected table In the dialog as shown in Figure 4.10, all attributes of the table are shown in the Attribute settings table. In the table, each row represents a column in the current table. There are five columns and their usages are: • Column name – The name of the column in the currently selected table. • Export – It indicates whether the values of such column are to be exported. If it is selected, the column values are to be exported. Otherwise, the column values will not be exported to the resultant XML document. • Type – There are two options provided for this column, either Attribute or Element. The default option Attribute indicates that the values of such column are to be exported as an element attribute. Otherwise, if you change it to Element, the value of such column is to be exported a sub-element of the XML element. Once a column is specified to be UXML User’s Guide 57 exported as sub-element, the list will be reordered so that the column becomes the last row in the table with a sequence number assigned in the Sequence column. • Name – It is the attribute (or element) name to be used for exporting such column. By default, it is the same as the column name with all spaces replaced with underscore characters (_). • More – If a column is set to be exported as Element, you can click the ellipsis (…) of the row to show the dialog as shown in Figure 4.11 to add a list of predefined attributes with values. Figure 4.11 The dialog for adding a list of predefined attributes with values of the element With the dialog as shown in Figure 4.11, you can specify an attribute name and the corresponding fixed value in a row of the table. When you are satisfied with the list of attributes with values, click OK to close the dialog. Click the Condition(s) tab so that the dialog becomes the one as shown in Figure 4.12 to specify the conditions for the current table. Figure 4.12 The dialog for specifying the conditions for the table 58 Data Export/Import The Column Name column shows all the columns of the current table and you can use the Condition column to specify the condition for that table column. The format of specifying the condition is the same as the dialog shown in Figure 4.6. To update the settings for another table, you can select it in the XML document structure pane and you can then change its settings. If you are satisfied with the settings for all tables, click Next to proceed to the next step of the dialog. Exporting XML documents with user-defined queries If you select the option Getting records by specifying a query in the dialog as shown in Figure 4.3 and click Next, the dialog as shown in Figure 4.13 will appear. Figure 4.13 The step of the Export table(s) as XML for specifying a user-defined query for getting the records to be exported The dialog shown in Figure 4.13 enables you to specify the structure of the XML document to be exported. The dialog initially denotes an XML document with root element only. You can then click Add Child Element to create child elements to the root element and the dialog will become the one as shown in Figure 4.14. UXML User’s Guide 59 Figure 4.14 The dialog for specifying a child element of the root element Then, you can provide a name for the query and a query in the Query name and Query (SQL) statement boxes respectively. The query to be provided can be any valid statement that can obtain records from the relation database to be accessed, and the record data must be sufficient to be exported to the XML document. Similarly, you can keep on adding child element to any existing element shown in the XML document structure pane. Click Next and the query statement you provided will be validated against the relational database you specified earlier with the dialog, and you will be prompted with error message if there is any error in the query. Otherwise, you will be prompted with the steps, as shown in Figure 4.6 to Figure 4.12 that are mentioned in the section Exporting XML documents without advanced data semantics, for you to specify namespace, XML document structures, conditions of the XML document to be exported and the corresponding schema. Specifying a password for the XML document You can optionally specify a password to encrypt the XML document to be exported, so that the document must be decrypted with the same password for processing its contents. It is especially useful if you are going to store the XML document in a publicly accessible directory or you have to send the document through an unsecured network, such as Internet. The dialog as shown in Figure 4.15 enables you to specify the password to be used while you are importing the XML document with UXML. 60 Data Export/Import Figure 4.15 The dialog for specifying the password for encrypting the XML document to be exported Specifying the schema to be generated Otherwise, you can use the next step of the Export table(s) as XML dialog as shown in Figure 4.16 to specify an optional schema, such as Data Type Definition (DTD) or XML Schema, to be generated. Figure 4.16 The step of the Export table(s) as XML dialog for specifying the schema to be generated As shown in Figure 4.16, most options in the XML settings region and XML schema settings regions are disabled for exporting XML document with advanced data semantics. Otherwise, the options in the two regions are enabled for you to specify the settings. You can use XML file to specify the file name of the XML document to be exported, and you can click the Browse button on the right of the XML file box to specify such file. UXML User’s Guide 61 In the XML schema settings region, you can specify the schema to be generated: • no associated schema – no schema is to be generated for the XML document to be exported, it is the default option. This option is preferable if you just want to export an XML document with the data. • XML with internal DTD – the schema in DTD format will be inserted to the exported XML document. • XML with external DTD – the schema in DTD format will be exported as an external DTD file and you can specify its file name with DTD file. You can click the Browse button at the right of the DTD file to specify the DTD file as well. Besides, you can specify the PUBLIC ID and SYSTEM ID with the PUBLIC ID and SYSTEM ID boxes respectively, and the SYSTEM ID is by default the name of the external DTD file. • XML with external XSD – the schema in XML Schema format will be exported as an external file and you can specify its file name with XSD file. Similarly, you can click the Browse button at the right of the XSD file to specify the XSD file as well. Select the View the generated file(s) on screen option so that the files are shown on the screen after the files are exported. Specifying a separated log file Click Next and the dialog will become the one as shown in Figure 4.17. Figure 4.17 The dialog enabling the user to specify a separated log file The dialog as shown in Figure 4.17 enables you to specify a separated log file to store the operation messages, so that you can easily identify the messages from others. Performing the operation and viewing the results Click Next and you will be prompted the step for storing the operation settings. Please refer to Chapter 6 for further details. On the dialog, click Finish to start the export process and a progress dialog will appears that looks like the one as shown in Figure 4.18 and the XML Viewer window as shown in Figure 4.19 will appear in the Working pane of UXML upon the completion of the operations. 62 Data Export/Import Figure 4.18 The progress dialog that appears while the XML document is exported The Close and Send buttons for closing and sending the current XML document The tabs for the different exported XML document. The different pages for the XML document, schema file and the DTD Tree for a particular exported XML document. The contents of a particular file according to the page you select. The Previous and Next button for showing a different section of the file Figure 4.19 The XML Viewer window The XML Viewer window can show the XML document, the schema file and a DTD Tree of the XML document depends on the files you generated with the export operations. To show the contents of another file or the DTD Tree, click the corresponding tab name at the top of the window. Besides, the XML Viewer window can show more than one XML document at the same time and you can click the tab for the XML document at the top of the window. If the size of a file cannot be loaded entirely to the computer memory, the file is loaded and shown section by section. As such, the Previous and Next buttons are enabled for you to view the previous and next section of the file respectively. Besides, there are two buttons, Close and Send, shown at the top of the window, for you to close the pages for the current XML document and send the current XML document via web services. For the details of sending XML documents via web services, please refer to Chapter 5. Visualizing XML document with XML Tree Model The XML elements and hence the data in the exported XML documents may be complicated that is hard to understand and visualize. In order to enable you to have a better understanding of the XML document, UXML enables you to visualize an XML document based on its corresponding DTD file. Therefore, if you export an XML document with external DTD file as its schema, there will be a page with tab name DTD Tree shown that is similar to the one shown in Figure 4.20. UXML User’s Guide 63 The miniature of the DTD Tree model The complete DTD Tree model of the XML document The Viewing region The scrollbars for scrolling and viewing a different region of the DTD tree model Figure 4.20 The DTD Tree page showing the DTD tree of an XML document based on its DTD file DTD tree model is an innovative way to visualize the structure and the relationships among the XML elements in the XML document. The tree structure of the DTD tree model visualizes the nested structure of the XML document and the circles on the diagram indicate the occurrence indicators and the each rectangle represents a particular XML element type that exists in the XML document. If there are linkages among the entities via ID/IDREF(S) type attributes, dot arrows are drawn to indicate these relationships. The DTD Tree page is divided into two panes that show the miniature and the entire DTD tree model respectively. For the miniature, there is a red rectangle that indicates the Viewing Region of the DTD tree model that is shown within the pane on the right. To view a different region of the DTD tree model, you can either use the scrollbars at the bottom and at the right of the right pane, or you can click on the miniature in the left pane so that the viewing region of the DTD tree model shown in the right pane is scrolled to show the clicked position immediately. Besides, if the left pane cannot accommodate the entire miniature, scrollbar(s) will appear at the bottom and at the right respectively. Besides, the entire DTD tree model shown on the right pane can be customized by moving the rectangle for an entity by dragging it to a new position. Importing XML documents to relational database If you are given an XML document, especially one exported from UXML, a possible way to handle such document is to import it to a relational database so that you can further manipulate the contents stored in the XML document with the relational database tools that you are familiar with. To import an XML document to a relational database, you can either, • Select File > Import From XML from system menu, or • Click Import XML on the system toolbar 64 Data Export/Import and the Import XML to database dialog will appear. The first step of the dialog enables you to specify a setting file so that the operation details are obtained. Please refer to Chapter 6 for further details. Click Next and the dialog will become the one as shown in Figure 4.21. Figure 4.21 The dialog for specifying the project or database settings to which the XML document is to be imported The dialog is divided into two regions, Source of settings and Database settings regions. If you are going to import the XML document to the associated relational database of an existing project, you can select the option Obtain settings from project and select the desired project from the list the follows the option. Then, the settings of the desired relational database will be shown in the Database settings region. Otherwise, you can select the option Enter new database settings in the Source of settings region and the entries in the Database settings region are enabled for you to specify the settings. The entries are exactly the same to the user entries that you provided when you create a new project. Click Next and the dialog will become the one as shown in Figure 4.22 so that you can specify the transaction option while importing the XML document. UXML User’s Guide 65 Figure 4.22 The dialog for specifying the transaction option There are totally four transaction options which are, • Auto Commit for each record – Each database operation, including deriving batch ID and inserting a record, is considered to be a single transaction. Failure in any single database operation will not cause other operations, which are otherwise valid, to rollback. For example, if a single element fails to be inserted to the database, other valid elements will be inserted, provided that they do not violate other referential integrity constraints. • Transaction for each sub tree in XML document – each sub-tree under the root element of the XML document is considered to be a transaction unit. That is, if there is any failure in inserting any element in the sub-tree, all elements in the sub-tree will not be inserted to the target database. • Transaction for entire XML document with batch ID – The tasks of getting batch ID from the database and inserting records are all handled as a single transaction. As such, if there is any failure in inserting the records, the operation of getting batch ID will be rollbacked as well. As such, the batch ID that is rollbacked will most probably be retried for the next import operation. • Transaction for entire XML document without batch ID – Importing an XML document involves two major tasks, which are firstly getting an optional batch ID from the database and subsequently actual insertions of the records. For this option, these two tasks are considered to be two separated transactions. As the entire XML document is inserted as a single transaction, if there is any error while inserting the records, all elements will not be inserted. However, as the task of getting the batch ID is considered to be a separated transaction, failure in inserting records for the corresponding XML elements will not rollback the operation of getting the batch ID. Select a particular option and click Next, the dialog will become the one as shown in Figure 4.23. 66 Data Export/Import Figure 4.23 The dialog for specifying the option for determining batch ID You can assign a batch identity (ID) for every import operation, so that the ID is to be stored in any column of any table or even multiple columns of more than one table in the target database. As such, you can easily identify the sources of the records in the database. It is especially useful if you are invoking UXML in script to be executed regularly. Select the option Batch ID enabled, you can select one of the following approaches for deriving the batch ID. • Timestamp – A textual representation of the time when the operation is performed is considered to be the batch ID. Choose this option can provide a pattern for deriving the textual representation while the import operation is carried out. The default pattern is year, month, day, hour, minute, second and millisecond. You can choose a suitable timestamp pattern based on your own requirement. For example, if you are going to carry out the import operation once a day, a pattern of year, month and day suffices. • Universal Unique Identifier (UUID) – UXML can derive a Universal Unique Identifier (UUID) that is unique at any time and by any machine. In other words, different UUID’s will be derived by the same machine at different time instances and two machines will derive different UUID’s even if they are deriving the UUID’s at the same time. • Execution of SQL statement(s) – The batch ID is obtained by executing a sequence of SQL statements, which involves at least one SQL statement. It is expected that the last SQL statement returns at least one records and the first field of the first record in the query result is considered to be the batch ID. UXML User’s Guide 67 The timestamp approach is suitable if you are using a single machine to import XML documents to the same relational database. However, if you use multiple copies of UXML to import XML documents to the relational database or the date/time of the machine would be adjusted regularly, timestamp approach may derive the same batch ID for different batch ID’s. As such, UUID approach is a better choice. Batch ID’s are determined by UXML for the above two approaches. The third approach delegates the determination of batch ID’s to the target relational database, so that there is a single source of batch ID’s. The sequence of SQL statements must be valid with respect to the target database. You should notice that if you choose this option and you specify the transaction option to be Transaction for entire XML document with batch ID, you can only import one XML document at any instance. It is because the operations of deriving batch ID by the relational database in a transaction mostly block the same set of operations. Click Next and the dialog will become the one as shown in Figure 4.24. Figure 4.24 The dialog for specifying the XML document to be imported The Import XML to database dialog as shown in Figure 4.24 enables you to specify the XML document to be imported. You can either enter the full path of the XML document to be imported or click Browse… to show a file chooser as shown in Figure 4.25 to locate it. With the file chooser, you can locate the desired XML document and click OK to close the dialog. Then, the full path of the selected file will be shown in the XML File box. 68 Data Export/Import Figure 4.25 The dialog for locating the XML document to be imported After you have specified the XML document to be imported, click Next on the Import XML to database dialog to proceed to the next step as shown in Figure 4.26. Figure 4.26 The second step of the Import XML to database dialog for specifying the destination relational database If you are going to import an XML document that was encrypted with a password by UXML, you can use the dialog as shown in Figure 4.26 to specify a password for decrypting the XML document to be imported. You can firstly select the option Password Protected and then specify the password in the Password box and re-enter it in the Password Again box. After you have specified the settings, click Next on the dialog to proceed to the next step as shown in Figure 4.27. UXML User’s Guide 69 Figure 4.27 The dialog showing the structure of the XML document and enable you to specify the elements to be imported as column of their parent element UXML will process the XML document to be imported for its structure. If a non-repeatable element type does not embed any sub element but just text, it can be considered to be an attribute (or column) of its parent element type (of the corresponding table). You can review the details of each element type by clicking it in the XML Structure pane and the details will be shown in the XML element details pane. For those element types that you think they are just attributes of parent element types, select the corresponding As parent column check boxes. If you are satisfied with the options, you can click Next to proceed to the next step as shown in Figure 4.28. Figure 4.28 The dialog for specifying the mappings between XML element types and tables in the target database The dialog as shown in Figure 4.28 enables you to specify the mapping of each element type with a target table in the relational database. All element types in the XML document are 70 Data Export/Import shown in the XML Elements pane. By default, all element types are to be skipped while importing the XML document and you can select an element type by clicking it in the pane to set the mapping by the pane on the right of the dialog. After an XML element is selected, you can then choose a target table from the Target Table list. Then, the structure of the selected table will be shown in the Element-column Mapping pane, such as the one as shown in Figure 4.28. Figure 4.29 The dialog after a target table is selected for a particular XML element type By default, all columns are to be skipped and you have to specify their settings for the import operation one by one. Click on the table and the Update Mapping pane will be shown as the following. Figure 4.30 The dialog for specifying the import setting for a particular column The Update Mapping pane is further divided into Column Details region and the Column Action Mapping region. The Column Details region shows the details of the current column UXML User’s Guide 71 and you can use the options shown in the Column Action Mapping region to specify the import settings. For each column, you can choose either one of the following options: • Skip – the column is skipped and no value is to be provided to the column while importing the record. This option is only applicable to null-able column or column with default values, especially the primary key of the table with automatic generated identity value. • Literal – a fixed value to be stored to the column. As such, the values of the column for all records to be inserted are the same. • Batch ID – the value of the batch ID determined by a previous step will be stored to the column. As such, records inserted by a single import operation will be the same, so that you can identify the records in the table for each import operation. • Expression – a valid expression or a sequence of SQL statements so that the first column value of the first record of the last SQL statement will be stored to the column. You have to make sure the value is compatible with the column type. • XML Document – the values to be stored to the column of the records are obtained from the XML document. You can specify an attribute of the corresponding element type by select the first option in the XML Document region and use the corresponding list to select an attribute, as illustrated in Figure 4.31. Besides, you can specify the source of the value from a parent element of the current element by selecting the second option in the XML Document region, and you can use the Column in RDB to select the source of the values as a column of the corresponding table of its parent element or use the XML Attributes list to select the attribute of its parent element to be the source of value for the column. Figure 4.31 The list in the XML document region for specifying the attribute of the XML element from which values are obtained to be stored to the column After you have specified the setting for a column, you can click Update to confirm the changes, or you can click Cancel otherwise. In either case, the dialog will show the Elementcolumn mapping pane again. Besides, you can use the Next and Previous button to navigate to the next and previous column of the table respectively, so that you can set their settings. 72 Data Export/Import When you navigate to other columns, the settings of the current column will be stored automatically. Specifying the settings for all columns can be tedious. If you are going to store an element type to a table with the same and with columns named identically to the element attribute, you can simply click Default Table and the table will be selected and the column import settings are determined automatically. Furthermore, you can click All Default at the bottom-left corner of the dialog so that default tables with default settings are to be specified for all element types in the XML document. If you found that there is no suitable table for storing XML elements, you can create a new table right away by clicking New Table, so that you can specify the settings with the new table. After you have specified all import settings, click Next to the next step for specifying a separated log file for each import operation, which is similar to the export operation. Then, you can click Next on the dialog to navigate to the next step of the dialog for saving the operation settings. Finally, click Finish and the import operation will be carried out immediately and dialog will be shown notifying you the operation result. You can see that importing an XML document to a relational database may not already succeed, and some of the involved operation may fail. The approach adopted by UXML is that all operations are performed sequentially no matter some operations cause problems or not. In future release of UXML, options will be provided to fine tune the import operation so that you can have an even better control of it. + & $$' & () * & Introduction Extensible Markup Language (XML) has been the de facto standard of storing structured data in the era of Internet. Its simplicity and extensibility makes it the ideal format for data storage, transformation and transmission. On the other hand, HyperText Transfer Protocol (HTTP) brings about the success of the World Wide Web (WWW). Since its introduction, more and more information has been made available via HTTP. Web pages written in HyperText Markup Language (HTML) obtained from web servers via HTTP are rendered by web browsers so that they are human readable. Even web pages written in HTML are quite similar to XML and web designers can use XHTML, which is an XML application dedicated to web pages, to compose web pages, the contents of the web pages are mostly for presentation purposes, such as for typeface styles and the layout of text and pictures. There is currently no standard approach to extract data from web pages, and web services standard was introduced as an alternative. Web Services HTTP is the most welcome communication protocol for obtaining information in various formats between different parties and in a heterogeneous computational environment. Furthermore, corporate firewalls are mostly by default allowing network connections via HTTP. With HTTP, it is possible for two application software to talk with each other by tailor-made request/response contents. However, such approach is proprietary which is not preferable, especially due to the fact that there is a well-defined standard out there. If the contents of web pages are purely XML documents that contain no formatting or presentation data, the embedded data are ready to be processed by usual software application, and such approach is know as web services. In order to further standardize the format of the XML document contents, a set of XML vocabularies has been introduced and it is known as Simple Object Access Protocol (SOAP). SOAP enables a software application to invoke another software application via HTTP and the data transmitted on the line are in XML format. Furthermore, the standard SOAP with Attachment enables supplementary data, even in non-XML format, to be sent. The support of Web Services by UXML UXML (non-education versions) can send XML documents to a web services server via SOAP with Attachment. Besides, UXML can embed a web services server that can natively retrieve the attached XML document and store the data to a relational database. Therefore, if both the sender side and the recipient side are running a copy of UXML, records stored in the source relational database at the sender side can be replicated to the target relational database at the recipient side via web services. Since the exported data are in XML format and UXML can handle the data types properly, it makes heterogeneous database replication possible. The 73 74 Data communication with Web Services typical scenario of using UXML for replicating database via web services is illustrated in Figure 5.1. Figure 5.1 The application of UXML for replicating database via web services The sequence of operations involved in the replication process illustrated in Figure 5.1 is: 1. The UXML running on the recipient side firstly starts the web services server that associates with the target database and some settings are pre-defined. Then, a Universal Resource Locator (URL) will be determined by UXML for sending XML documents via web services. 2. The UXML running on the sender side exports the necessary data from the source database as an XML document. 3. Based on the URL of the web services running on the recipient side, the sender side UXML prepares the SOAP message with the exported XML document as attachment and sends it to the web services server at the recipient side. 4. The SOAP message will (and mostly has to) pass through the firewalls running on both the sender and recipient sides. If necessary, Virtual Private Network (VPN) or Secure Socket Layer (SSL) can be used to provide a secure network communication on the way via the Internet so that the data will be neither tampered nor read by unauthorized parties. 5. Once the recipient side web services server receives the XML document, the document is firstly stored in its secondary storage, such as the computer drive. Then, the data stored in the XML document will be extracted and are stored to its associated database according to the pre-defined settings. During the process of storing the records, errors may occur and are recorded by the UXML running on the recipient side. 6. After the entire XML document are processed by the UXML running on receiver side, all collected error messages are stored in a SOAP reply message and is sent back to the UXML running on the sender side. 7. Based on the SOAP reply message, the UXML running on the sender side will show the end user the results of sending the exported XML document. UXML User’s Guide 75 The web services server running on the recipient side can support more than one sender simultaneously with different settings, such as the associated database and the import settings. The scalability is only limited by the resources of the machine running the UXML, such as its memory and its network connections with the Internet and the associated database servers. Starting a web services server The web services server is responsible for listening to the web services requests, which is structured according to the SOAP specification, sent from UXML or other web services enabled software applications. Provided that the messages adhere to the standard specified by SOAP with Attachment and the attachment is a valid XML document, the web services server will extract and handle the XML document from the SOAP message accordingly. UXML can extract the data from the XML document and import them to the corresponding tables in the desired relational database and the entire XML documents to a native XML database server. To start a new web services server, select Tools > Start XML Receiver from the system menu or click Start XML Receiver on the system toolbar, and a dialog as shown in Figure 5.2 will appear. Figure 5.2 The first step of the New XML receiver dialog for specifying the network settings In the dialog as shown in Figure 5.2, the first step is to specify the information for the URL of the web services server, including the Internet Protocol (IP) address, port number and a context name. As a computer can associate with more than one IP address, you can instruct the web services server to listen to one of the address or all IP addresses of the machine. By default, the option (All addresses) is chosen in the IP address(es) to listen list indicating that the server will listen to all IP addresses of the machine. You can use the Port number box to specify the port number the web services server is listening. The default port number for HTTP is 80 but such port number is most probably reserved. Therefore, a default port number 8000 is specified here. 76 Data communication with Web Services You can choose any integer ranged from 1 to 65535 as the server port number, provided that: 1. the port number is not currently used by another process running on the same machine, and 2. the firewall running on the firewall and your machine, if any, must allow that network connection to such port of your machine, and 3. For UNIX clone (and Linux), port numbers less than 1024 are reserved and you must executing UXML with root privilege if you want to use any one of them for the web services server. You can further specify a context name by the Context name box and the default one is just / which is the root context. If the context name is /, which is for the root context, the URL of the server will be: http://<IPAddress>:<portNumber>/receiveXML Otherwise, the URL of the server will be: http://<IPAddress>:<portNumber>/contextName/receiveXML Click Next to proceed to the next step as shown in Figure 5.3 for specifying the database server for storing the data derived from the XML documents to be received by the server. Figure 5.3 The second step of the New XML receiver dialog for specifying the database settings For the second step of the New XML receiver dialog, options are provided enabling you to specify the database settings to be used for importing the data obtained from the received XML document via web services. The User entry pane is divided into two regions, the Source of settings and the Database settings regions that are at the top and at the bottom of the User entry pane respectively. If you want to use the database settings of an existing project, that is you are going to store the data derived from the received XML document to the associated relational database of that project, you can select the project name from the Obtain settings from project list and the corresponding database settings will be shown in the Database settings pane. UXML User’s Guide 77 On the other hand, you can specify new database settings for the relational database to which the derived data from the XML document to be received are stored. If so, select Enter new database settings in the Source of settings region and the entries in the Database settings region will be enabled for you to specify the database settings, which are similar to the necessary database settings when you create a new project. Click Next and the dialog will verify the database settings to make sure the database server is accessible and next step of the dialog as shown in Figure 5.4 will appear. Otherwise, a dialog with error messages will be shown. Figure 5.4 The third step of the New XML receiver dialog for specifying a DTD that can valid the XML documents to be received As the web services server is opened to receive any SOAP message, which embeds an arbitrary XML document or even non-XML document, it is necessary to specify a schema of the XML document, which is a Document Type Definition (DTD), that the server can handle and the XML document will only be processed if the XML document is valid with respect to it. Enter the file name of the DTD file in the DTD File box or you can click Browse… to show a file chooser dialog for you to locate the desired DTD file. Select the desired DTD file with the file chooser and click OK to close it. After the DTD file is specified, click Next to proceed to the next step as shown in Figure 5.5. 78 Data communication with Web Services Figure 5.5 The fourth step of the New XML receiver dialog that shows the necessary tables for storing the data with their current status and action to be performed Based on the DTD, the XML element types that may exist in the XML document to be received are determined, and UXML will verify whether the existences of the corresponding tables in the specified database. Then, the dialog as shown in Figure 5.5 shows all the necessary tables based on the XML element types specified in the DTD file for you to specify the action to be performed on them. There are four possible actions from which you can choose for each table. Option Description Skip All elements of such element type are skipped. No tables will be created and no records are inserted to the database. Create temp table/insert For every received XML document, a new temporary table will be created and all elements of such type will be inserted to the newly created table. Create if not exist/insert Upon the recipient of an XML document, a new table will be created if no corresponding table exists. Then, no matter the table is newly created or originally existing, all elements of such element type will be inserted to the table. Create if not exist/delete/insert Upon the recipient of an XML document, a new table will be created if no corresponding table exists. If the table originally exists, all existing records are firstly removed and all elements of such element type will be inserted to the table then. Specify the actions for different tables and when you are satisfied with your entries, click Next to proceed to the next step of the dialog. UXML User’s Guide Figure 5.6 79 The fifth step of the New XML receiver dialog for specifying the structures of the necessary tables to be created If you specify some tables are to be created in the previous step as shown in Figure 5.5, the dialog as shown in Figure 5.6 will appear for you to customize the table structures. On the other hand, the dialog will be skipped if no tables are to be created specified by the previous step. The DTD not only can be used to validate the XML documents to be received and handled, but also can be used to derive the necessary tables and columns for storing the XML elements defined in the received XML documents. The methodologies are: • For each XML element type with at least one attribute, a table in the target relational database with the same name is the corresponding table for storing all instances of such XML element type. • For each attribute defined for a particular XML element type, a column with the same name of the corresponding table is the column for storing the attribute values of the XML elements. • The corresponding column is nullable if the attribute is optional or non-nullable otherwise (which correspond to #IMPLIED and #REQUIERD specified for an attribute respectively). • As all data stored in an XML document is in textual format, all column types are by default text or VARCHAR that is supported by most relational database. • Since it is not possible to specify the maximum attribute length with DTD, the default column sizes for all are 255. For example, regarding the following DTD, <!ATTLIST My_Table Field_1 CDATA #IMPLIED Field_2 CDATA #REQUIRED> the following table structure will be derived, 80 Data communication with Web Services CREATE TABLE My_Table ( Field_1 VARCHAR(255), Field_2 VARCHAR(255) NOT NULL ) You can find all the tables that are to be created in the previous step in the Table list. Select a table from the list, the default table structure to be created is shown in the Table structure table and the following settings can be specified. • Name – the column name to be created. • Key – the corresponding column is one of the columns of the primary key of the table if it is selected. • Type – the type of the data to be stored in such column and the possible data types are DATE, DATETIME, NUMERIC and VARCHAR. The default data type is VARCHAR. • Size – the column size and the default is 255. • Digit – the number of digits to be used for the fractional part if the column type is NUMERIC. • Nullable – the column can contain NULL value if it is selected. Otherwise, the column is non-nullable and XML elements with the corresponding attribute missing cannot be inserted into the corresponding table. • Pattern – If the type of a field is set to be DATE or DATETIME, you can specify a Pattern so that the attribute value are parsed according for the actual date/time. For example, you can enter dd/MM/yyyy as the pattern for parsing date values, so that 01/12/2005 will be handled as December 1, 2005 and is inserted to such field of the table. After you are satisfied with the structure for a table, you can select another table in the Table list to set the structure for that table. If you are satisfied with all table structures, click Next to proceed to the next step of the dialog as shown in Figure 5.7. Figure 5.7 The sixth step of the New XML Receiver dialog for specifying a native XML database for storing the received XML documents UXML User’s Guide 81 You can specify a native XML database in the dialog as shown in Figure 5.7 that can be used to store all XML documents received by the web services server. To specify a XML database server, you have to firstly select the option Store received XML document and the other entries are enabled for you to specify the settings, which are: • Server type – the XML database server type. For instance, only the Tamino XML database server by Software AG is supported. • Host/IP Address – the host name or the IP address of the machine that hosts the XML database server. • Database – the name of the database for storing the received XML documents. • Collection – the name of the collection to which the received XML documents are stored. If you specify to store the XML documents with a native XML database server and you are satisfied with the specified settings, click Next to proceed to the last step of the dialog as shown in Figure 5.8. Figure 5.8 The last step of the New XML receiver dialog for you to confirm the properties of the web services server to be started If you are satisfied with the settings shown in the dialog as in Figure 5.8, click Finish and the web services server will be started accordingly. UXML shows you a dialog, which looks like the one as shown in Figure 5.9, telling you the URL of the web services server if the server starts successfully. Figure 5.9 The dialog showing the web services server has been started with the URL for receiving XML document via web services 82 Data communication with Web Services Otherwise, a dialog with error messages will appear telling you the cause of the failure in starting the server. Based on the error messages, you can repeat the above steps with corresponding settings adjusted accordingly. As the error messages may due to network problem or database problem, it may be difficult for you to figure out the actual cause. In such case, please contact our support team with detailed error messages for assistance. Once an embedded web services server is started, the Server Message pane as shown in Figure 5.10 will appear showing the messages generated by the web services server for handling incoming XML documents. Server Message pane Figure 5.10 The Server Message pane is shown after a web services server is started Whenever the web services server receives an XML document via web services, a message is shown in the Server Message pane. If you want to investigate the details of the message, you can highlight the message for handling a particular received XML document in the table and click Details, the XML Receiver Operation Log dialog as shown in Figure 5.11 will appear. UXML User’s Guide 83 Figure 5.11 The XML Receiver Operation Log dialog showing the details for handling a particular received XML document To show the cause of a particular error message, you can either • double-clicking a particular error message in the table, or • select a particular error message by clicking it and click Show Details the Details page of the dialog as shown in Figure 5.12 will be shown showing the cause of the selected error message. 84 Data communication with Web Services Figure 5.12 The dialog showing the cause of a particular error message At any time when a web services server is up and running, you can review its settings by clicking Properties in the Server Message pane and the XML Receiver Properties dialog as shown in Figure 5.13, which is pretty much the same as the one shown in Figure 5.8, will appear. Figure 5.13 The XML Receiver Properties dialog Multiple web services servers UXML can host more than one web services servers with different settings and associating with different databases. As such, you can run a single copy of UXML for replicating the records to different target databases at the recipient side. However, you have to make sure UXML User’s Guide 85 each web services server is listening to a different network port (and hence different port number) of the machine. Otherwise, starting the second web services server for a used network port will prompt you with a dialog containing some error messages. Starting a web services server for a particular port number will add a new tabbed page named Port: <Port Number> in the web services Server Message pane for that web services server. Stopping a web services server A web services server survives as long as UXML is running, and you can explicitly terminate it. For example, if you want to start another web services server to listen to a currently used port number or importing received XML document data to another relational database, you have to firstly stop such web services server. To stop a particular web services server, you have to firstly identify the web services server by clicking the tab name in the web services Server Message Pane for the web services server to be terminated. For example, to stop the web services server associated with port number 8000, you have to firstly select the tab named Port: 8000 by clicking the tab name. Then, click Stop at the lower-right corner of the Server Message Pane to terminate the server explicitly. Once a web services server is stopped, the port number it used will be now available to be used by another web services server to be started. Sending XML document via web services Creating an XML document by exporting records from a relational database with UXML, the document will be shown in the XML Viewer. In the XML Viewer Window as shown in Figure 5.14, you can click Send to show the dialog as shown in Figure 5.15 for sending the XML document to the desired web services server. The Send buttons for sending the current XML document Figure 5.14 The Send button on the XML Viewer Window for sending the current XML document via web services 86 Data communication with Web Services Figure 5.15 The Send XML via HTTP dialog for sending the current XML document via web services In the dialog as shown in Figure 5.15, you can specify the IP address, port number and context name of the web services server to which the XML document to be sent. The IP address, port number and the context name can be derived based on the URL of the web services server for receiving an XML document in the format: http://IpAddress:PortNumber/ContextName /receiveXML Once the settings are specified, click Finish to send the XML document shown in the XML Viewer. On return, a Result of sending XML document dialog will appear showing whether errors occurred while updating the target database. For example, the dialogs shown in Figure 5.16 and Figure 5.17 will appear for the cases with and without error messages respectively. UXML User’s Guide 87 Figure 5.16 The dialog for showing the error messages generated and returned by the recipient web services server Figure 5.17 The dialog showing no errors were encountered for handling the sent XML document by the recipient web services server If a dialog as shown in Figure 5.16 appears providing you the list of errors that were encountered by the web services server at the recipient side, you can select a particular error message in the table by clicking it and click Show Details or simply double-clicking it to show the cause of such error, as shown in Figure 5.18. 88 Data communication with Web Services Figure 5.18 The cause of an error message on the Details page The web services server will keep on handling the XML document it receives via web services. Therefore, you can continue to send other XML documents to the same web services server or another one started by another UXML running at another recipient side probably with a different set of web services server settings. - " , , As UXML is a feature rich and powerful software application, it enables you to control the every detail of the operation at the expense that you have to provide the entries one by one, especially for those operations that are started with a dialog. If these operations with the same setting are performed over and over again, it is both time-consuming and error prone to specify those operation settings every time the operation is performed. In view of these, for some operations that you may perform repeatedly, UXML enables you to save the settings for an operation to a setting file, so that you can load the file to execute exactly the same operation without specifying the settings again. For instance, the following is a list of operations that enable you to store the settings. • Export relational databases as XML documents • Import XML documents to relational databases • Start XML Receiver Further operations may support loading and saving operation settings in newer version of UXML according to the feedbacks from the end-users. Please contact our customer services telling us the operations that you want to perform repeatedly with stored operation settings. Saving the operating settings For the operations that support setting storage and retrieval, the last step of the dialog will be the one as shown in Figure 6.1. Figure 6.1 The dialog for storing the operation settings 89 90 Operation settings To save the settings that you specify (other than the settings you provided for the first step if the first step is to load operation setting from a setting file), select the option Save operation settings to file and the Setting file box will be enable for you to specify the target setting file to be created. Besides, you can click Browse… to show a file chooser dialog to specify the target setting file. After you specify the setting file, click Finish and all operation settings are stored to the specified setting file and the operation will be performed accordingly. Loading the operation settings For the operations that support loading existing operation settings from setting file, the first step of the dialog will be the one as shown in Figure 6.2. Figure 6.2 The dialog for loading the operation settings If you want to perform the operation with new settings, select the Specify new settings option, which is the default one, and click Next to start specifying the new settings. Otherwise, select the Load settings from file option and you can then use the Setting file box to specify an existing setting file, or you can click Browse… to locate the setting file. You should make sure that the setting file is dedicated to the operation you are going to perform. If you want to perform the operation with the settings stored in the setting file, select Skip customization option and click Next will perform the operation right away. Otherwise, you can use the subsequent steps of the dialog to fine tune the operation settings. For the details of the subsequent steps, please refer to the corresponding chapter in this User’s Guide. If you want to amend the settings stored in a setting file, you can load the settings from the file with the first step of the dialog. Then, you can use the subsequent steps to change the settings. Finally, you can use the last step of the dialog to store the settings to the same setting file or a new one. . $ & One-to-one relationship Rule: A foreign key of a child table addresses to a primary key of a parent table in one-to-one occurrence. Explanation: • A parent table consists of a primary key that is addressed by a child table in a relationship. • A child table consists of a foreign key that addresses to a primary key of a parent table in a relationship. • A primary key is an attribute (column) that uniquely identifies a tuple (row) in a table. • A foreign key is an attribute addressing to a primary key in another table. A data occurrence is a tuple in a table. Example: Each patient must have one and only one medical record folder. Extended Entity Relationship Diagram: Figure A.1 One-to-One Cardinality Relational Model: Relation Patient (HKID, Patient_Name) Relation Medical_Record_Folder (Folder_No, Location, *HKID) where underlined are primary keys and “*” prefixed are foreign keys 91 92 Data Semantics One-to-many relationship Rule: A primary key of a parent table is addressed by many foreign keys of child tables in one to many occurrences. Explanation: • A parent table consists of a primary key that is addressed by a child table in a relationship. • A child table consists of a foreign key that addresses to a primary key of a parent table in a relationship. • A primary key is an attribute (column) that uniquely identifies a tuple (row) in a table. • A foreign key is an attribute addressing to a primary key in another table. • A data occurrence is a tuple in a table. Example: A director directs many movies. Extended Entity Relationship Diagram: Figure A.2 One-to-many cardinality Relational Model: Relation Director (Director_Name, Age) Relation Movies (Movie_Name, Sales_Volume, *Director_Name) where underlined are primary keys and “*” prefixed are foreign keys Many-to-many relationship Rule: A primary key of a parent table is addressed by many foreign keys of child tables in one to many occurrence and vice versa. These two tables are in many to many cardinality. Explanation: • A parent table consists of a primary key that is addressed by a child table in a relationship. • A child table consists of a foreign key that addresses to a parent table in a relationship. UXML User’s Guide • • • • 93 A primary key is an attribute (column) that uniquely identifies a tuple (row) in a table. A foreign key is an attribute addressing to a primary key in another table. A data occurrence is a tuple in a table. The component of the primary key of a relationship relation of two tables in m: n cardinality must address to the primary key of each one of the two tables. Example: Many students take many courses such that a student can take many courses and a course can be taken by many students. Extended Entity Relationship Diagram: Figure A.3 Many-to-many cardinality Relational Model: Relation Student (Student_ID, Student_Name) Relation Course (Course_ID, Course_Name) Relation Take (*Student_ID, *Course_ID) where underlined are primary keys and “*” prefixed are foreign keys ISA (Subtype) relationship Rule: A sub-class table is a (ISA) super-class table such that the data occurrence of a sub-class table is a subset of its super-class table. Explanation: • The data occurrences of a subset table reside in its super-class table. • A super-class table consists of the data occurrences of all its sub-class tables. • The sub-class table consists of a “dual” (primary and foreign) key addressing to its super-class table. Example: Father is Male. 94 Data Semantics Extended Entity Relationship Diagram: Figure A.4 Is-a relationship Relational Model: Relation Male (Name, Height) Relation Father (*Name, Birth_Date) where underlined are primary keys and “*” prefixed are foreign keys Disjoint Generalization Rule: Two sub-class tables are in disjoint generalization provided that all of their data occurrences are mutual exclusive with each other, which are subset of a common super-class table. Explanation: • The data occurrences of a subset table reside in its super-class table. • A super-class table consists of the data occurrences of all its sub-class tables. • The sub-class table consists of a “dual” (primary and foreign) key addressing to its super-class table. • Two sub-class tables are mutual exclusive if their tuples are not duplicated in each other. Example: A refugee and a non-refugee can both be a boat person, but a refugee cannot be a nonrefugee and vice versa. Extended Entity Relationship Diagram: Figure A.5 Disjoint Generalization UXML User’s Guide 95 Relational Model: Relation Boat_Person (Name, Birth_Date, Birth_Place) Relation Refugee (*Name, Open_Center) Relation Non_refugee (*Name, Detention_Center) where underlined are primary keys and “*” prefixed are foreign keys Overlap Generalization Rule: Two sub-class tables are in overlap generalization provided that all of their data occurrences are inclusive with each other, and they are subset of a common superclass table. Explanation: • The data occurrences of a subset table reside in its super-class table. • A super-class table consists of the data occurrences of all its sub-class tables. • The sub-class table consists of a “dual” (primary and foreign) key addressing to its super-class table. • Two sub-class tables are inclusive if their tuples can be duplicated in each other. Example: A computer programmer and a system analyst can both be a computer professional, and a computer programmer can also be a system analyst and vice versa. Extended Entity Relationship Diagram: Figure A.6 Overlap Generaliation Relational Model: Relation Computer_Professional (Employee_ID, Salary) Relation Computer_Programmer (*Employee_ID, Language_Skill) Relation System_Analyst (*Employee_ID, Application_System) where underlined are primary keys and “*” prefixed are foreign keys Categorization Relationship Rule: A sub-class table is a subset of a categorization of its super-class tables. Explanation: A sub-class table is a subset of a union super-class tables such that the data occurrence of a sub-class table must appear in one and only one super-class table. 96 Data Semantics Example: A patient record borrower can be a department, a doctor or a hospital. Extended Entity Relationship Diagram: Figure A.7 Categorization Relationship Relational Model: Relation Department (Borrower_Card, Department_ID) Relation Doctor (Borrower_Card, Doctor_Name) Relation Hospital (Borrower_Card, Hospital_Name) Relation Borrower (*Borrower_Card, Return_Date, File_ID) where underlined are primary keys and “*” prefixed are foreign keys Aggregation Relationship Rule: An aggregation table must consist of multiple component tables. Explanation: • A tuple of an aggregation table must consist of the tuples of its component tables. • The component of the primary key of an aggregation table is also a foreign key addressing to the primary key of its component tables. Example: The process of a student taking a course can form a composite entity (aggregation) that may be graded by an instructor if the student completes the course. UXML User’s Guide 97 Extended Entity Relationship Diagram: Figure A.8 Aggregation relationship Relational Model: Relation Student (Student_No, Student_Name) Relation Course (Course_No, Course_Name) Relation Takes (*Student_No, *Course_No, *Instructor_Name) Relation Instructor (Instructor_Name, Department) where underlined are primary keys and “*” prefixed are foreign keys Total Participation Rule: A child table is in total participation with a parent table provided that all data occurrences of the child table must participate in a relationship with the parent table. Explanation: A foreign key of a child table in total participation must address to the primary key of its parent table and cannot be a null value. Example: An employee must be hired by a department. Extended Entity Relationship Diagram: Figure A. 9 Total Participation 98 Data Semantics Relational Model: Relation Department (Department_ID, Department_Name) Relation Employee (Employee_No, Employee_Name, *Department_ID) where underlined are primary keys and “*” prefixed are foreign keys Partial Participation Rule: A child table is in partial participation with a parent table provided that the data occurrences of the child table are not totally participate in a relationship with the parent table. Explanation: A foreign key of a child table in partial participation must address to the primary key of its parent table and can be a null value. Example: An employee may be hired by a department. Extended Entity Relationship Diagram: Figure A.10 Partial Participation Relational Model: Relation Department (Department_ID, Department_Name) Relation Employee (Employee_No, Employee_Name, &Department_ID) where underlined are primary keys and “&” prefixed are foreign keys that can be null value. Weak Entity Rule: The existence of a weak entity depends on its strong entity. Explanation: A weak entity depends on its strong entity such that the primary key of the weak entity is also a foreign key addressing to the primary key of its strong entity, and cannot be a null value. Example: A hotel room must concatenate hotel name for identification. Extended Entity Relationship Diagram: UXML User’s Guide 99 Figure A. 11 Relationship between Strong and Weak Entities Relational Model: Relation Hotel (Hotel_Name, Ranking) Relation Room (*Hotel_Name, Room_No, Room_Size) where underlined are primary keys and “*” prefixed are foreign keys N-ary Relationship Rule: Mulitple tables relate to each other in an n-ary relationship. Explanation: An n-ary relationship is a relationship relation for multiple tables such that components of the former’s compound primary key addressing to the primary key of the latter which are related to each other. Example: Employees use a wide range of different skills on each project they are associated with. Extended Entity Relationship Diagram: Figure A.12 N-ary Relationship Relational Model: Relation Engineer (Employee_ID, Employee_Name) Relation Skill (Skill_Name, Years_Experience) 100 Data Semantics Relation Project (Project_ID, Start_Date, End_Date) Relation Skill_Used (*Employee_ID, *Skill_Name, *Project_ID) where underlined are primary keys and “*” prefixed are foreign keys