Coders often fall upon the requirement to change the way they work with their databases, this is usually the case when say, being a engineer you can be working on a web application.
Coders often fall upon the requirement to change the way they work with their databases, this is usually the case when say, being a engineer you can be working on a web application or possibly a software project and you realize you should improve your data mid flow, by way of example, moving from xml data to some relational database.
I have often worked on projects in which the goals have moved and in some cases, new technologies are actually brought in which has necessitated the need for a different data methodology.
Having excellently handled this sort of transition in large projects, the process itself is definitely not an arduous one; the key struggle is in mapping the data layout concerning the sender and the destination data.
The best way to accomplish this is by using an xml schema (xsd for short), basically an xml schema is a strategy to illustrate the structure and content of an xml data source. The schema sets out the foundations of an xml file, the same as a DTD. This means schema will set out to specify the elements, attributes, child elements, order and number of child elements etc that can appear in the xml data source.
For you to map your xml database, you may use the following approaches, at the present time there isn't any one desired method or in truth procedure to follow, the below methods can be viewed as a series of logical steps. I'd also add that the method you're taking is going to be governed by your own particular circumstances, like the nature and type of data you would like to map.
Element To Table MappingChanging xml elements into relational database tables could be the most obvious path to take, however it's not absolutely the very best, its viability will probably be dependant on your data. As an example, mapping an element right into a database table will certainly transform the columns to element attributes or the element content into children and so on.
To map a target element to a relational database table, simply setup the mapping node to collect the relevant rows from the database, then fill the target elements with values from your database.
Element To Column MappingMapping elements to columns in your relational database is usually recommended when you have uncomplicated elements containing only text string, if your elements is made up of further elements or attributes, your mapping is more unlikely to achieve success. By default, an element or even attribute of simple type, maps to the column with the same name in the table.
In the illustration below, the <Person.Person> element is of complex type and also, due to this fact, maps by default to the Person.Person table in the selected database. The attributes (BusinessEntityID, FirstName, LastName) of the <Person.Person> element are of simple type and map by default to columns with the same names in the Person.Person table.
<xsd:schema xmlns:xsd=".w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-mysite-com:mapping-schema">
<xsd:element name="Person.Person" >
<xsd:complexType>
<xsd:attribute name="BusinessEntityID" type="xsd:string" />
<xsd:attribute name="FirstName" type="xsd:string" />
<xsd:attribute name="LastName" type="xsd:string" />
</xsd:complexType>
</xsd:element>
</xsd:schema>
Attribute To Column MappingAttribute to column mapping will work better if you would wish to map the attributes into columns inside your relational database tables, matching them to their given elements.
The exclusion is where you simply have a set volume of possible attribute values, in this particular circumstance it might be better to have distinctive tables for the elements needing each attribute type.
Let’s say you could have an element designated “brick”, that has an attribute named “colour”, additionally, the attributes can only be “red” or “grey”, you might implement it by setting two tables, one for red bricks and the other for grey bricks.
| Additional articles about xml |
|
|
| About the author |
Michael Dupre is an veteran practitioner in XML coding as well as XML standards and possesses an array of working understanding of Data Mapping plus highly recommends you to Data Mapper.
|
| Please Rate This Article |
Number of ratings: 0
Rating: 0