CSDL (Conceptual Schema Definition Language) is the schema language available under the OSP of the ODP (Open Data Protocol). ODP is a technology that originated at Microsoft and is spreading from there.
I suspect it is the nail in the coffin for W3C XSD: small is beautiful! CSDL models the Entity Data Model (an entity-relationship (ER) model.) I think CSDL is to RDBMS data what RELAX NG is to publishing-documents and reports.
Classifying schema languages
When we look at schema languages, there are three basic issues (even though usually schema languages don't present themselves as functions, but as equations which some data will satisfy):
- What is the input data structure?
- What kind of grammar is the schema language?
- What is the output data structure? (Is the schema language defined as a recognizer or transducer?)
For example, in RELAX NG the input is an attribute-value tree (XML), the grammar is regular (and ambiguous), and the output is a boolean (valid or invalid.) Of course, an application is free to produce richer information as the output of validation, but it is not in the standard.
Schematron's default, in contrast, is that the input is an XPath Data Model (a directed coloured rooted graph, a path-rich XML), the grammar is context-free (because of XPath variables and current()), and the output is an XML attribute-value tree (i.e., SVRL).
XSD's input data structure is an attribute-value tree (XML), the grammar is regular (and non-ambiguous: the famous UPA for example), and the output is a non-XML tree (PSVI).
CSDL's input data structure is a multi-rooted, directed, possibly cyclic graph: in particular, the Entity Data Model: entities and associations; the grammar is regular, and the output is not defined. However, it seems that can be used for serialization, for validation and for data import back into an RDBMS.
How does CSDL manage to have a graph as its input, if it is XML? By the simple trick of defining a simple wrapper element: Entity Data Model for Data Services Packaging Format (EDMX). All your entities can go below that.
Other CSDL characteristics of interest
- CSDL does not share anything with XSD. It has a data type declaration system that looks the same, but it does specify (to make it all clear) that all datatypes are derived from xs:string. Any attempt to reconcile the two type systems is therefore application dependent, not standard. There is a simple facet system for creating new datatypes (derivation by restriction, but CSDL does not use type derivation terminology.)
- CSDL does support kinds of choices and a thing called a ComplexType, in which order is important. But these are exceptions rather than the usual case.
- For multiplicity on associations, CSDL allows 0..1, 1,* at each end.
- Functions can be defined.
- Referential constraints allow a kind of parent/child relationship to be declared.
- Probably the most interesting thing to me in CSDL is the onDelete element:
<OnDelete> is a trigger that is associated with a relationship. The action is performed on one end of the relationship when the state of the other side of the relationship changes.
The example given is
<End Type="Self.CProduct" Multiplicity="*" />
<End Type="Self.CCategory" Multiplicity="0..1">
<OnDelete Action="Cascade" />
"Cascade" is not a very illuminating word. But I think the idea is that (in order to support delete-ish operations) the strength of coupling between entities needs to be modeled: i.e., is the coupling between the entities which are ends of an association so strong that if the first is deleted, the other should also be deleted (and should this be cascaded).
This seems to me to be a really important and useful idea, and one could be applicable to any graph-based or schema language, including Schematron.