Database
  Home arrow Database arrow Page 9 - Extracting Metadata
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Extracting Metadata
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 18
    2004-09-08

    Table of Contents:
  • Extracting Metadata
  • Introducing the Process
  • Using Schema Definitions Such As XSD
  • Extracting Metadata from Databases Such As SQL Server
  • Retrieving Metadata from External Sources
  • Extracting Metadata from Design Tools Such As UML
  • Extracting Metadata from Existing Applications and Source Code
  • Why Extract Metadata?
  • Establishing Your Own XML Design Guidelines
  • Introducing the Tools for Metadata Extraction
  • Understanding XSD’s Role in Code Generation
  • Exploring the Structure of an XSD
  • Working with SQL-92 Databases (SQL Server)
  • Understanding the Tool Architecture
  • Working with Information Schema Views
  • Using Constraints
  • Modifying Mappings
  • Retrieving Stored Procedure Recordsets
  • Retrieving Identity Columns
  • Creating Freeform Metadata
  • Using Skip Attributes
  • Merging Metadata

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Extracting Metadata - Establishing Your Own XML Design Guidelines


    (Page 9 of 22 )

    How do you design XML? The same data can be expressed in XML in a multitude of ways—how do you settle on one? It helps to articulate a set of rules you can use to ensure consistency. My rules are as follows:

    • Use attributes for data that can logically occur just once and is a reasonable length.

    • Pay careful attention to elements’ names—ensuring they describe the breadth of what they can contain now and in the future.

    • Use child elements for items that can possibly occur multiple times.

    • Separate child elements by category and generally use grouping elements such as Tables.

    • Use plurals only in the grouping elements, and use correct grammar and spelling for plurals.

    • Unless it’s unavailable or illogical, all elements have an attribute named Name that contains the logical name for the data item. This name is unique at least within the parent element.

    • Use Pascal casing for element and attribute names. (See Footnote 10.) 

    NOTE This is a potential trouble spot, particularly for VB developers because XML tools are case sensitive.

    • Minimize abbreviations in element and attribute names.

    • Use "true" and "false" for Boolean values.

    • In general, preserve raw data within the XML document when massaging is done. For example, when changing a database type to a .NET type, preserve the original database type name, as well. You can break this rule when you specifically remove information to simplify the XML document, such as you’ll see in Chapter 6.

    • Use a consistent style for namespaces (urn, uri, and so on).

    • Expect to infer XSD schemas, so try to incorporate its rules, particularly not repeating element names in different contexts, and test XSD inference early and often.

    • Use prefixes for all namespaces—avoid using empty namespaces or default namespaces.

    (Footnote 10. Pascal case has the first character capitalized as well as the start of any new logical word. An example of Pascal casing is DataTable. This is sometimes confused with camel casing in which the first letter isn’t capitalized. For example, dataTable is camel casing. It helps me remember the difference that a camel has humps only in the middle. Pascal casing isn’t standard for XML and XSLT files, but I think it makes the files more readable.)

    NOTE:  There’s nothing magic about this set of rules. The magic is having any specific set of rules that you can turn to when you’re wondering “Should this be an attribute or element?” or “How should I name this element?”. I hope your organization can agree on a set of rules and allow it to evolve. I’ll warn you that I’m imperfect and slip up sometimes even on my own rules.

    Using these rules, as well as rules for legal XML, the design of the metadata begins to emerge. You need a root element and want its name to imply the full breadth of data that might be contained in the file. It’s helpful to include the word Root, such as MetadataRoot. The root contains grouping elements. For example, DataStructures contains the information about individual data schemas. You might think about naming the data schema root Databases, but that’s too restrictive because the data may be contained in many forms such as XML, config files, transfer from external programs, and so on. The first cut at the monolithic metadata file is as follows:

    <?xml version="1.0" encoding="utf-8" ?>
    <MetadataRoot >
      <dbs:DataStructures FreeForm="true" xmlns:dbs="http://kadgen/DatabaseStructure">
        <dbs:Tables<>/dbs:Tables>
        <dbs:UserDefinedTypes<>/dbs:UserDefinedTypes>
        <dbs:StoredProcedures<>/dbs:StoredProcedures>
        <dbs:Functions<>/dbs:Functions> 
        <dbs:Views<>/dbs:Views> 
      </dbs:DataStructures>
      <ffu:UIStucture xmlns:ffu="http://kadgen/FreeFormForUI.xsd" />
      <OtherStructures></OtherStructures>
      <ClassStructures></ClassStructures>
    </MetadataRoot>

    This is from Code Generation in Microsoft .NET, by Kathleen Dollard (Apress, ISBN 1590591372). Check it out at your favorite bookstore today. Buy this book now.

    More Database Articles
    More By Apress Publishing


     

    DATABASE ARTICLES

    - Building Applications with Anonymous Types
    - A Closer Look at Anonymous Types
    - Programming with Anonymous Types
    - Converting Your Excel Worksheet into a Worki...
    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek