I am using mysql. I can optionally add hard coded relationships between tables in mysql by use of foreign key and make it cascade or restrictive for example. My question is, design wise, would it be bad to rely on the code only without setting the relationships in mysql? For example, below code doesn't necessarily need hard relationships in mysql to work.
PHP Code:
$post = $this->join('post_files', 'post_files.post_id = posts.id AND post_files.primary = `Y`', 'inner')
->join('post_images', 'post_images.post_id = posts.id AND post_images.primary = `Y`', 'inner')
->join('post_descriptions', 'post_descriptions.post_id = posts.id AND post_descriptions.primary = `Y`', 'inner')
->find($id);
![[Image: 18P5uZ.jpg]](http://snipboard.io/18P5uZ.jpg)
![[Image: MpzJnC.jpg]](http://snipboard.io/MpzJnC.jpg)