Clemens Ladisch skrev 2012-11-09 17:00:

Thanks alot for the help! :)

Are you sure that the normalization hasn't gone a *little* bit too far?

Yes, it makes perfect sense in other parts of the application.

FOREIGN KEY( unit_id ) REFERENCES unit_types ( id )
Why is this column not called unit_type_id?

It's a typeo I made when creating the example for the question I posted here, thanks for pointing it out though :)

Just use SQL to generate the SQL query:

SELECT 'SELECT units.id AS "unit id"' AS SQL
UNION ALL
SELECT ', cv' || id || '.value AS ' || quote(name) FROM configtypes
UNION ALL
SELECT 'FROM units JOIN unit_types ON units.unit_type_id = unit_types.id'
UNION ALL
SELECT 'LEFT JOIN (unittype_config JOIN configvalues' ||
        ' ON unittype_config.configvalue_id = configvalues.id' ||
        ' AND unittype_config.configtype_id = ' || id || ') AS cv' || id ||
        ' ON unit_types.id = cv' || id || '.unit_id' FROM configtypes

Seems interesting, but I don't understand how I use this type of construction to create the view? It builds up the requested query, but shows the sql query as text output (not executing it)?

Best Regards,
Daniel
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to