How to use constraints (MySQL) for existent (installed) tables

System info
PHP Version: 7.3.27
mysql version: 5.6.41-84.1
Web server: Apache
Client: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.132 Safari/537.36

Hello,

I am learning to use Dadabik and I have the following doubt: What is the correct way to add a new constraint to a mysql table that is already installed on my dadabik application?

I need to do it because I think this is the only way in Dadabik to restrict deletion of child records in a master detail relationship. Am I wrong about this?

I was thinking about to use the DB Syncro for this but it would work only if i rename, delete or add fields.

Pehaps I just need to uninstall the table then install it again (and configure Permissions and Form Configurator again... Ouch!).

Am I in the correct way?

Thanks in advance
Celson
 
After some time thinking about this I am starting to think I can add constraints to my MySQL database (I can even do it by using phpMyAdmin if I don't want to use a MySQL Design Tool like MySQL Workbench) and it will not affect my dadabik application (I don't need to uninstall/install tables after doing it).

If somebody have any experiences with this subject, please confirm.

Thank you in advance!
 

eugenio

Administrator
Staff member
Hello Celson,
you got it right; let me explain a little bit more: DaDaBIK (only with MySQL) uses your referential integrity constraints (I think you are referring to ref. int. constraints here and not to constraints in general) only when you install dadabik or install a table. If DaDaBIK sees a ref. int. constr., it configures the related foreign key as lookup field.

However, setting ref. int. constr. in your db is anyway a very good practice, it's one of the tool you can use to try to preserve your data integrity.

I am not sure if I have understood your example with child records: a ref. int. constr. in this case could prevent the deletion of the "master" record, not of the child records.

Best,
 
I took a look on my text in the first thread above and I really wrote it wrong:


The correct text would be:

"I need to do it because I think this is the only way in Dadabik to restrict deletion of a master record when there are child records in a master detail relationship. Am I wrong about this?"

Thank you!
 
Top