MySQL Forums
Forum List  »  Newbie

Enforcing the data integrity through MySQL or PHP?
Posted by: huizhang66
Date: April 28, 2005 12:25PM

I am using MySQL and PHP for the web programming.

For a database backed small to middle size e-commerce web sites, (several hundreds products to no more than 5000 products).

When we try to enforce the data integrity of the database, I know it is better to do both through MySQL database and PHP. But in some cases, if you have to choose, will you do it through php scripts or through MySQL?

Through the database, we have the foreign keys and other constraints, domains, alertions to enforce the data integrity.

And we can also use php scripts to enforce these rules too.

Specially, like the foreign keys rules, such as delete/update a parent with a child. We can simply enforce the data integrity (such as is child is not reassigned, you cannot delete/update the parent, or update the child with the parent at the same time) through php. Is it necessary or better to do it through MySQL foreign key constrains and rules instead of php?

Also such as if the data value only allowed [1, 2, 3, 4, 5], should we use the domain of MySQL to enforce it, or should we just simply enforce this rule in php? and then when we need to change it to allow the values of [1, 2, 3, 4, 5, 6, 7], we can change the php scripts directly? To make the web running smoothly, we need to check this rule in php first anyway.

In simple words, consdiering quality and cost, roughly, in what kind cases, you would enforce the data integrity both in MySQL and php, or only in MySQL, or only through php?

Thanks!

Options: ReplyQuote


Subject
Written By
Posted
Enforcing the data integrity through MySQL or PHP?
April 28, 2005 12:25PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.