Foreign key or Relations - Setup in the DCT or PostgreSQL?

Hi guys.
I wanted to take a doubt with you, I’m starting now with Clarion and PostgreSQL, and I would like to know, what better way to perform a relationship between tables, would it be through DCT, or PostgreSQL?

Put foreign keys in PG so it will do the data integrity work for you (ie cascade deletes to child tables, restrict deletes when a child exists). Put foreign keys in the DCT for coding convenience (ie allows easy entry of a range rather than adding the condition as a filter). 99% of the time, my foreign keys in the DCT are not unique, just the fields necessary to link parent-child controls. I no longer enter table relationships in the DCT, instead preferring to specify the join condition directly for tables in a procedure.

Bottom line in my opinion, put as much into PG that you can.

1 Like

I tend to have both. But if the relationship is defined in pg then the dct has ‘cascade server’.
There are also times when I have a relationship defined in Clarion but not on the server. Those are the times when Clarions lack of checking at insert time is an advantage, but the DB has a hissy fit.

But I agree, I’m in the put lots into the database camp.

One other reason for everything in PG - there might come a day when Clarion code is not the only code using and writing the data.