I agree with the w / cdragon recommendation below to avoid option # 2. Choosing between # 1 and # 3 is heavily influenced by style. I like to use attributes for what I consider attributes of an entity, and elements for what I consider to be data. It is sometimes difficult to classify. However, they are not “wrong.”
And while we are on the topic of circuit design, I’ll add two cents regarding my preferred level of (maximum) reuse (both elements and types), which can also facilitate the external “logical” linking of these entities in, say, a data dictionary stored in the database data.
Note that while the Garden of Eden scheme offers maximum reuse, it also includes most of the work. At the bottom of this article, I have provided links to other templates described in the blog series.
& bull; The Garden of Eden Approach http://blogs.msdn.com/skaufman/archive/2005/05/10/416269.aspx
It uses a modular approach, defining all elements globally and, like the Venetian Blind method, all type definitions are declared globally. Each element is globally defined as an immediate child of a node, and its type attribute can be set to one of these complex types.
<?xml version="1.0" encoding="UTF-8"?> <xs:schema targetNamespace="TargetNamespace" xmlns:TN="TargetNamespace" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"/> <xs:element name="BookInformation" type="BookInformationType"/> <xs:complexType name="BookInformationType"/> <xs:sequence> <xs:element ref="Title"/> <xs:element ref="ISBN"/> <xs:element ref="Publisher"/> <xs:element ref="PeopleInvolved" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> <xs:complexType name="PeopleInvolvedType"> <xs:sequence> <xs:element name="Author"/> </xs:sequence> </xs:complexType> <xs:element name="Title"/> <xs:element name="ISBN"/> <xs:element name="Publisher"/> <xs:element name="PeopleInvolved" type="PeopleInvolvedType"/> </xs:schema>
The advantage of this approach is that schemes can be reused. Because both elements and types are globally defined, both are reusable. This approach offers the maximum amount of reusable content. The disadvantages are that the scheme is verbose. This would be a suitable design when creating shared libraries in which you can allow yourself to make any assumptions about the scale of elements and types of schemes and their use in other schemes, especially with regard to extensibility and modularity.
Since each individual type and element has one global definition, these canonical particles / components can be connected one-to-one with identifiers in the database. Although this may seem like a tedious routine at first glance, to maintain the relationship between text particles / XSD components and the database, SQL Server 2005 can actually generate canonical component identifiers through the statement
CREATE XML SCHEMA COLLECTION
http://technet.microsoft.com/en-us/library/ms179457.aspx
Conversely, to build a schema from canonical particles, SQL Server 2005 provides
SELECT xml_schema_namespace function
http://technet.microsoft.com/en-us/library/ms191170.aspx
sa · not · i · kal Related to math. (equations, coordinates, etc.), "in the simplest or standard form" http://dictionary.reference.com/browse/canonical
Other, simpler to construct, but less resultant / more "denormalized / redundant" schema schemes include
& bull; The Russian Doll approach http://blogs.msdn.com/skaufman/archive/2005/04/21/410486.aspx
There is one global element in the scheme - the root element. All other elements and types enter deeper, deeper, giving it a name due to the fact that each type is adjusted to what is above it. Because elements in this design are declared locally, they will not be reused using the import or include statements.
& bull; Salami Slice Approach http://blogs.msdn.com/skaufman/archive/2005/04/25/411809.aspx
All elements are defined globally, but type definitions are defined locally. Thus, other schemes can reuse elements. With this approach, the global element with its locally defined type provides a complete description of the contents of the elements. This informational “slice” is declared individually and then aggregated back together and can also be brought together to build other schemes.
& bull; The Venetian Blind Approach http://blogs.msdn.com/skaufman/archive/2005/04/29/413491.aspx
Similar to the Russian Doll approach, as they use one global element. The Venetian Blind approach describes a modular approach by naming and defining all type definitions globally (as opposed to the Salami Slice approach, which declares global elements and types locally). Each globally defined type describes an individual “tablet” and can be reused by other components. In addition, all locally declared elements can be either a qualified namespace or a namespace (sections can be “open” or “closed”) depending on the parameter attribute elementFormDefault at the top of the schema.