Hi all.
My situation is as follows:
I have a normalized database, in which I hold geographic information about airports. The structure is:
airport --is in--> city --is in--> country --is in--> continent
Now I want to let users administrate this data, without giving them direct access to the database. We need to offer this administration interface via a web service.
Now, when it comes to designing the service, we ran into the discussion about how to define the operations. We came up with different solutions:
Solution A: specific operations
For each of the four tables (airport, city, country, continent) we define 3 operations:
- insert
- get
- update
This would lead to 12 operations with 2 request/response objects = 24 objects
To create an all new airport with all dependencies, at least 4 requests would be necessary.
Solution B: generic
There is only one operation, which is controlled via parameters. This operation is capable of creating everything needed to administer the database.
The operation would decide what needs to be done and executes it. If an error occures, it will roll back everything.
==> 1 Operation = 2 highly complex request/response-objects
Solution C: Meet in the middle 1
One generic operation per table, which is capable of executing get, insert, update, just like solution B, but focused on one table each.
==> 4 operations = 8 complex request/response-objects
Solution D: Meet in the middle 2
One generic operation per action (get, insert, delete), which can work on each table and resolve dependencies.
==> 3 operations = 6 slightly more complex request/response-objects
Example
Since this was rather abstract, hier a simplified example for request-objects for creating (JFK/New York/USA/North America):
Solution A:
Request 1/4:
<insertContinent>North America</insertContinent>
Request 2/4:
<insertCountry continent="North America">USA</insertCountry>
Request 3/4:
<insertCity country="USA">New York</insertCity>
Request 4/4:
<insertAirport city="New York">JFK</insertAirport>
Solution B:
Request 1/1:
<action type="insertCountry" parent="North America">USA</action>
<action type="insertAirport" parent="New York">JFK</action>
<action type="insertContinent" parent="">North America</action>
<action type="insertCity" parent="USA">New York</action>
Solution C:
Request 1/4:
<countryAction type="insert" parent="North America">USA</countryAction>
Request 2/4:
<airportAction type="insert" parent="New York">JFK</airportAction>
Request 3/4:
<continentAction type="insert" parent="">North America</continentAction >
Request 4/4:
<cityAction type="insert" parent="USA">New York</cityAction >
Solution D: Request 1/1:
<insert airport="JFK" city="New York" country="USA" continent="North America" />
Solution D seems rather elegant for me, therefore I tried to put this in XSD:
Code:
<complexType name="NewContinent">
<sequence>
<element name="NAME" type="string"></element>
</sequence>
</complexType>
<complexType name="NewCountry">
<sequence>
<element name="ISOCODE" type="string"></element>
<element name="NAME" type="string"></element>
<choice>
<element name="newCONTINENT" type="tns:NewContinent"></element>
<element name="CONTINENT" type="string"></element>
</choice>
</sequence>
</complexType>
<complexType name="NewCity">
<sequence>
<element name="IATA" type="string"></element>
<element name="NAME" type="string"></element>
<choice>
<element name="COUNTRY" type="string"></element>
<element name="newCOUNTRY" type="tns:NewCountry"></element>
</choice>
</sequence>
</complexType>
<complexType name="NewAirport">
<sequence>
<element name="IATA" type="string"></element>
<element name="NAME" type="string"></element>
<choice>
<element name="CITY" type="string"></element>
<element name="newCITY" type="tns:NewCity"></element>
</choice>
</sequence>
</complexType>
A corresponding request would then look like follows:
<complexType name="Request">
<choice>
<element name="AIRPORT" type="tns:NewAirport"></element>
<element name="CITY" type="tns:NewCity"></element>
<element name="COUNTRY" type="tns:NewCountry"></element>
<element name="CONTINENT" type="tns:NewContinent"></element>
</choice>
</complexType>
Now my question: Is this really the best solution available? Is the XSD enough to understand, what is going on?
Best regards and TIA!