Home Page   We Generate Your Software.
Products Services Company Technology Demo Contact Site Map Search

Full list of in-depth articles - Feedback and questions - Request demo -


Extracting metadata from Oracle with SoProMach

  1  Mining and analyzing metadata: CSV vs. XML
  2  Model generation: XML and Somusar EF (Entity Files)
  3  Mining Oracle metadata with SoProMach
  Appendix A  Further information
  Appendix B  Summary of metadata extracted in CSV format

Rearchitecting or rebuilding existing applications with code generation may happen for several reasons, such as changing part of the original technology or adding a new architectural layer. Independently of the reason, in most cases a key requirement concerns the existing databases: if their performance has been satisfactory, it is required that they be used without changes as the foundation for the new or rearchitected applications. In some cases, a project of this kind also provides an opportunity for rearranging the architectural style originally applied, and to build a new model that extends the expected life span of the applications.

This article describes a model generation scheme utilizing SoProMach that allows model architects to effectively acquire knowledge and gain control of existing databases.

1 - Mining and analyzing metadata: CSV vs. XML

The experience gathered so far has shown that a two-stage approach to model generation provides some significant advantages in comparison with a one-stage approach:

  • the first stage may provide detailed (even redundant) information in a format suitable for automatic processing and analysis;

  • the second stage may abstract from the unrelevant or redundant details of the first stage, and produce a base model in a format more appropriate for the model architect's work.

In our case, comma-separated value (CSV) files have proven to be a better alternative than XML in the first stage for the following reasons:
  • non-developers are familiar with row-column spreadsheets: CSV makes it thus easier to involve business reviewers in the analysis stage;

  • CSV files can be easily processed with ad-hoc Unix-style filters, producing statistics on existing databases' internal details.

Moreover, the low-level engine of SoProMach (Tefigel: see overview and reference) provides agile means to process CSV files and perform the second model-generation stage.

2 - Model generation: XML and Somusar EF (Entity Files)

The analysis of the intermediate CSV files and the new or extended architecture provide the guidelines for the second stage of model generation. These guidelines have been realized in our case in the form of Tefigel scripts to be applied on the CSV files. Outcome of these scripts can be XML, EF (Somusar Entity Files - see examples), or both.

If the software generator chosen for the actual development project is SoProMach, as in our case, then the obvious choice is EF, that provides robust type-checking and flexible entity aggregation mechanisms. But XML is an excellent metadata exchange medium, so in our case it was decided to generate an EF model, and export XML metadata from EF at software-generation time.

3 - Mining Oracle metadata with SoProMach

Chapter "Extracting Metadata" from Kathleen Dollard's "Code Generation in Microsoft .NET" provides an excellent introduction to metadata extraction. Particularly relevant to the contents of this article is paragraph "Extracting Metadata from Databases Such As SQL Server".

The specific solution described in this article allows to extract metadata from Oracle9i Sample Schemas HR, OE, QS and SCOTT (see "Oracle's Sample Schemas: Saying Goodbye to Scott" and "Oracle9i Sample Schemas - Part Number A96539-01"). By means of SoProMach and SQL*Plus this solution extracts metadata about the following classes of constructs:

  • tables and constraints;

  • views;

  • stored procedures and functions;

  • user-defined types.

The overall process of this specific solution is shown in the figure below.

Figure 1 - Extracting metadata from Oracle9i

Figure 1 - Extracting metadata from Oracle9i

The numbers in the figure correspond to the steps described below. Steps 1 to 7 (continuous lines) are project-independent; steps 8-10 (dashed lines) are project-specific.

  1. The Model Architect runs the desired metadata extraction job on the desired schema(s). Note that the Model Architect could be an automated tool;

  2. SoProMach generates on the fly a set of scripts, similar to the queries that an Oracle DBA would type into a SQL*Plus console;

  3. SoProMach submits each script to SQL*Plus;

  4. SQL*Plus interacts with the RDBMS and retrieves the metadata;

  5. The raw metadata is written by SQL*Plus into a set of text files;

  6. SoProMach parses the raw metadata, understanding the required amount of SQL code output by SQL*Plus; note that steps 2 to 6 are automatically repeated to fetch metadata about tables, views, and stored procedures (and possibly more);

  7. The interesting part of the metadata is rearranged and stored into CSV files;

  8. CSV files can be examined and analyzed by the Model Architect as plain spreadsheets, or processed by record-oriented tools such as "awk";

  9. Depending on the project target, the Model Architect runs SoProMach to generate new software, or to produce a new model (XML, or .ef, for instance) for later processing;

  10. According to the target of step #9, SoProMach transforms the uniform metadata into more complete metadata, or directly into software.

Appendix A - Further information

This solution has been tested with Oracle9i Release 2 running on Linux, and SQL*Plus running on both Windows and Linux. It has been implemented with SoProMach/Community Edition.

SoProMach/Community Edition and a set of proofs-of-concept are available for free download. All documentation on SoProMach is available on line. For more information please contact us.

Appendix B - Summary of metadata extracted in CSV format

The uniform CSV metadata files produced in step #7 are listed below.

HR/procedure.add_job_history.summary.csv
HR/procedure.secure_dml.summary.csv
HR/table.countries.summary.csv
HR/table.departments.summary.csv
HR/table.employees.summary.csv
HR/table.job_history.summary.csv
HR/table.jobs.summary.csv
HR/table.locations.summary.csv
HR/table.regions.summary.csv
HR/view.emp_details_view.summary.csv
OE/table.categories_tab.summary.csv
OE/table.customers.summary.csv
OE/table.inventories.summary.csv
OE/table.order_items.summary.csv
OE/table.orders.summary.csv
OE/table.product_descriptions.summary.csv
OE/table.product_information.summary.csv
OE/table.product_ref_list_nestedtab.summary.csv
OE/table.subcategory_ref_list_nestedtab.summary.csv
OE/table.warehouses.summary.csv
OE/type.catalog_typ.summary.csv
OE/type.category_typ.summary.csv
OE/type.composite_category_typ.summary.csv
OE/type.corporate_customer_typ.summary.csv
OE/type.cust_address_typ.summary.csv
OE/type.customer_typ.summary.csv
OE/type.inventory_list_typ.summary.csv
OE/type.inventory_typ.summary.csv
OE/type.leaf_category_typ.summary.csv
OE/type.order_item_list_typ.summary.csv
OE/type.order_item_typ.summary.csv
OE/type.order_list_typ.summary.csv
OE/type.order_typ.summary.csv
OE/type.phone_list_typ.summary.csv
OE/type.product_information_typ.summary.csv
OE/type.product_ref_list_typ.summary.csv
OE/type.subcategory_ref_list_typ.summary.csv
OE/type.warehouse_typ.summary.csv
OE/view.bombay_inventory.summary.csv
OE/view.oc_corporate_customers.summary.csv
OE/view.oc_customers.summary.csv
OE/view.oc_inventories.summary.csv
OE/view.oc_orders.summary.csv
OE/view.oc_product_information.summary.csv
OE/view.product_prices.summary.csv
OE/view.products.summary.csv
OE/view.sydney_inventory.summary.csv
OE/view.toronto_inventory.summary.csv
QS/table.aq$_aq$_mem_mc_h.summary.csv
QS/table.aq$_aq$_mem_mc_i.summary.csv
QS/table.aq$_aq$_mem_mc_nr.summary.csv
QS/table.aq$_aq$_mem_mc_s.summary.csv
QS/table.aq$_aq$_mem_mc_t.summary.csv
QS/table.aq$_mem_mc.summary.csv
QS/table.aq$_qs_orders_pr_mqtab_h.summary.csv
QS/table.aq$_qs_orders_pr_mqtab_i.summary.csv
QS/table.aq$_qs_orders_pr_mqtab_nr.summary.csv
QS/table.aq$_qs_orders_pr_mqtab_s.summary.csv
QS/table.aq$_qs_orders_pr_mqtab_t.summary.csv
QS/table.qs_orders_pr_mqtab.summary.csv
QS/table.qs_orders_sqtab.summary.csv
QS/table.sys_iot_over_9709.summary.csv
QS/table.sys_iot_over_9733.summary.csv
QS/view.aq$aq$_mem_mc.summary.csv
QS/view.aq$aq$_mem_mc_s.summary.csv
QS/view.aq$qs_orders_pr_mqtab.summary.csv
QS/view.aq$qs_orders_pr_mqtab_r.summary.csv
QS/view.aq$qs_orders_pr_mqtab_s.summary.csv
QS/view.aq$qs_orders_sqtab.summary.csv
SCOTT/table.bonus.summary.csv
SCOTT/table.dept.summary.csv
SCOTT/table.emp.summary.csv
SCOTT/table.salgrade.summary.csv


Written on 6 December 2004 - Updated on 6 September 2005
Full list of in-depth articles - Feedback and questions - Request demo -

http:// www.somusar.com  / company  / news  / in_depth  / ora_meta  - Powered by SoProMach
Copyright © 2003-2012 Somusar - Trademarks - Legal - Privacy - Webmaster