I know PHP but am new to database design ( I usually work with some CMS and use PHP to build out features, pages, etc.). I’m building an app from scratch and I find myself wondering “should I let MySQL handle this task or should I code it out using PHP?”.
So for example, I have a tagging feature. I can tag contacts so they are organized. I don’t want a user to create the same tag. I can require the tag name to be unique in the database and upon inserting a duplicate tag name the database will simply ignore it (not create a duplicate record). Or I can code up some PHP to check to see if the submitted tag exists and prompt them that no duplicates are allowed.
See what I mean here? It seems like you get into the situation where you can handle things on the coding end (PHP) or at the datasource (MySQL). And perhaps this is where triggers and views on the MySQL side come into light too although I know nothing about those currently.
Just wanted some thoughts on this topic.