cipher-naught wrote on Saturday, July 21, 2012:
Brady -
1) Support legacy codebase - for patient_data table
I think there might have to be some discussion about the best way to implement some of the new “multitude of data” supported with the new design. For example there is only one name available to a patient now, how do we make backward compatibility work for the new design that supports more than one name.
(I could see some type of design supporting some type of priority legal > medicare > other or something like that.)
Simplify queries
- I have run into the opposite problem with views, them not taking hold when they should. For example if I get used to typing:
select * from person
inner join person_first_name on person.person_id = person_first_name.person_id
inner join person_last_name on person.person_id = person_last_name.person_id
where person.person_id = 12 and person_first_name.type='legal' and person_last_name.type='legal'
When I could have used the
view_Person_Legal_Name
table forgetting that the view is easier to use (for lines of text and typos) than the joins above.
As to the thought of using modular php functions/classes - I think it can be a two edged sword. Databases are very, very efficient at data processing. Take an example of having two views on the
view_person_legal_name
and the other
view_person_business_name
(maps a person to a business name). With these two views you could have a query like this:
select view_person_business_name.business_name from view_person_legal_name
inner join view_person_business_name on
view_person_legal_name.person_id = view_person_business_name.person_id
where person_id = 12
Now if you have that code in php you might have this:
$businessObject->getBusinessName($personObject->getBusinessIDByPersonID($personID));
Now you could just say well we should create a single method that fetches both these values which is fine, but then you are copying the SQL around everywhere. But in the end it is just a value judgement.
It is the same parallel to Business Logic in the Database (a good link from Martin Fowler). Should all business logic be at the code level? (Another discussion for another day, perhaps.)
But my point pro-view point is:
1) Makes database level programming/SQL easier
2) Centralizes data model access to reduce common mistakes (joins that look right, but aren’t).
3) I feel it makes programming easier and cleaner since the code becomes easier to read since there are less joins, etc.
Fortunately, you can probably argue every one of these points in the opposite manner and still be right.
I don’t think there is a one single pure answer to this, like so many things it is a balance.
-cipher-naught