One approach would be to write a separate tool that connects to the
database and writes out a representation of the schema to a source
file. At compile time, the representation is statically imported, and
used to verify the data model.
what about data/fields that don't comes out of the model?
for example:
select
name_length_add_1,
count(*) as counted
from
(
select
(len(p.firstname) + 1) as name_length_add_1,
p.*
from
persons as p
inner join members as m on p.firstname == m.firstname
) as blub
group by
name_length_add_1
how is the "counted" field or "name_length_add_1" staticaly verified?
people tend to think that sql is just simple table querying stuff - but
thats not, not in the real world