I am trying to implement the following:
In a database I wish to implement a GENERIC datamodel, thus on a meta-level. All RELATIONS (part of a MODEL) will be a view on some base (being a table) JOINed with (an) extra column(s). Thus, this view consists of a number of FIELDS. I whish to make this view editable (INSERT, UPDATE) using the RULE system. Some constraints will apply; enforcing these is the problem I am trying to solve by modeling these rules with a table "RELATION_CONSTRAINTS" (see below).
Tables:
BASE(col1, col2, col3)
MODELS(name)
RELATIONS(modelname, name)
FIELDS(modelname, relation_name, name, datatype)
RELATION_CONSTRAINTS(modelname, relation_name, constraint_name, constraining_expression)
I was thinking of implementing this using a FUNCTION that takes a polymorphic record parameter (and the relation name); then checking this record against the applicable constraint _expression_.
This whole idea may sound like a DBMS-in-a-DBMS kind of thing... What I am trying is to write as little as table/view-specific code as would be necessary, while still collecting all base data in one central table...
All suggestions are very much appreciated,
regards,
Rob