Download as PDF

Extension of data model and data consistency

version 1 by Daniel Neumann

Requirements

No more prerequisites are needed for these tutorials than for the preceding tutorials.

Description

In the first tutorial you learn how to extend an existing data model. We do this using the example of the quotation administration created beforehand. Following on from this, the second tutorial explains the data consistency in onion.net.

Extension of the data model

We want to extend the schema for a quotation to include the indication of a source. To do this, we first extend the schema to include an optional element.Wir wollen das Schema für ein Zitat um die Angabe einer Quelle erweitern. Dazu erweitern wir das Schema zunächst um ein optionales Element.

For this purpose, you select the schema “quotation” in the schema administration. Extend the <xs:sequence/> to include a further element:

<xs:element name="origin" type="xs:string" minOccurs="0" />

We now supplement the existing quotations with the missing data.

Select your quotations in the detail view. Check them out and enter the source of the quotations, e.g. “zitate.net” and then return them.

We can now remove the attribute “minOccurs “. The source indication is thus compulsory for future quotations.

Go back to the schema “quotation” and delete the attribute “minOccurs” from the xs: element.

Thanks to the extendable data types you can always adapt onion.net projects to new requirements.

Data consistency

Now add a new, non-optional element “date” in the schema:Fügen Sie im Schema nun ein neues, nicht-optionales Element „date“ hinzu:

<xs:element name="date" type="xs:dateTime" />

Saving this schema extension is not possible since the existing objects of this type would then be invalid. Indeed, clicking on the save button leads to the following notice:


By optionally configuring the element we keep the existing objects valid.

Join the attribute “minOccurs='0” to the element “date” and save the schema again.

The consistent validation of the data by the defined schemas makes it impossible to create invalid contents.