> > Thanks for your quick response, Anthony. If I got it correctly, it would > be working as expected if I changed the test_id type from integer to id. I > gave it a try, but it only raised some errors (missing required field) >
Changing "test_id" to type "id" should work, but you might need to start with a fresh table, as an "id" type field is an auto-incrementing integer field. > and more importantly, it did not allow me to insert this field manually. > Is there some other approach to reference other value than id? > You wouldn't set the value of an id field manually. Why do you need a separate test_id field -- if it is unique per record, the automatically generated id field should work? In any case, why do you need test_counts.test_id to be the tests.test_id field rather than the tests.id field? In the latter case, you can still access the tests.test_id field (via a join or second query), and cascading deletes will work fine as well (i.e., when a record in tests is deleted, referencing records in test_counts will also be deleted). Anthony