lazy validation on complex criterion
lazy validation on complex criterion
От:
Ivan Sergio Borgonovo <mail@webthatworks.it>
Дата:
I've this set of tables:
- A hold some choices made by user
- X groups A records
- B hold some other choices made by user
- C hold all the possible choices that can be put in B and
parametrised criteria when they can be chosen according to values
stored in A
something like
create table X (
id serial primary key
);
create table A (
fkid int not null references X (id) on delete cascade
fieldA1 int,
fieldA2 int,
fieldA3 int
)
create table C (
id serial primary key,
crit1M int,
crit2M int,
crit3M int,
...
)
create table B (
fieldB1 int not null references C (id) on delete set null,
...
)
now fieldB1 could be chosen among
rule:
select C.id from (
select sum(A.fieldA1) as c1, [some other function on A]
where A.fkid=[some id in X]
) as _subquery
where _subquery.c1