Useful Design Patterns
The cost and time to design new data models can be brought down when combining a number of typical solutions into a new one. Reusing certain design patterns is advisable because it is very efficient to have solution features which quickly lead to a reliable result.
In this message we discuss :
-(Multiple) Self Referring Trees
-A bit about Time driven modelling.
ListLet's assume we need a concept country for our solution. The most simple format we can think of is a data object called Countries. It enables us to list all countries of the world and select from them.
Now suppose we like to limit the country choice list per continent for a bit more user convenience. A typical solution would be to add a new data object Continent.
Self referring tree + List
We all know reality is more complex and therefore let's assume we need a concept called Region to store data on. This can be organised in a simple self referencing tree whereby we can model the regiontypes like continent, country, state, department,etc in a simple list.
Multiple self referring trees and link lists
When we only require geographical system this would be sufficient. However when we want regions to be member of multiple Regional groupings we need a bit more complex construction.
The data object NestedRegionTypes contains different regional grouping systems like:
- -USA (country) of North America (continent)
- -France (country) of Europa (continent)
- -Netherlands (country) of Europa (continent)
- -Texas (state) of USA (country)
- -Haute Provence (Region) of France (country)
- -Utrecht (province) of Neth)erlands (country
One can now add grouping systems of any type to the database and directly use them without any programming effort. For example the collection of ''Kantons speaking a particular language in Switzerland'' can be added in two steps.
First create a grouping system of lingual division in the dataobject NestedRegionTypes.
Secondly link the relevant Swiss Regions to their lingual group in the dataobject RegionLink
- Geneva, French
- Graubunden, Romansh
- Ticino, Italian
- Schaffhausen, German
More time driven flexibility
Finally, to add a bit more flexibility, when membership to grouping systems vary in time you can give them a start- and enddate attribute to filter out the non-current regions at any give moment.
Let's take as an example the Commonwealth of Nations established in 1931, today a group of 54 countries. The entries in the RegionLink data object look like:
- Commonwealth, Australia, 1931, today
- Commonwealth, SriLanka, 1948, today
- Commonwealth, Tanganyika, 1961, 1964
- Commonwealth, Ireland, 1931, 1949
That's it for now, hope you found any of the solutions useful for your application.