views:

75

answers:

3

Hi guys,

I'd like to hear some opinions or discussion on a matter of database design. Me and my colleagues are developing a complex application in finance industry that is being installed in several countries.

Our contractors wanted us to keep a single application for all the countries so we naturally face the difficulties with different workflows in every one of them and try to make the application adjustable to satisfy various needs.

The issue I've encountered today was a request from the head of the IT department from the contractors side that we keep the database model in terms of tables and columns they consist of.

For examlpe, we got a table with different risks and we needed to add a flag column IsSomething (BIT NOT NULL ...). It fully qualifies to exists within the risk table according to the third normal form, no transitive dependency to the key, a non key value ...

BUT, the guy said that he wants to keep the tables as they are so we had to make a new table "riskinfo" and link the data 1:1 to the new column.

What is your opinion ?

+1  A: 

This question is indeed subjective like what Binary Worrier commented. I do not have an answer nor any suggestion. Just sharing my 2 cents.

Do you know the rationale for those decisions? Sometimes good designs are compromised for the sake of not breaking currently working applications or simply for the fact that too much has been done based on the previous one. It could also be many other non-technical reasons.

o.k.w
I agree .. sometimes .. compromised .. non-technical reason. I understand its necessity in some cases.Just don't feel like it when a simple table needs another flag column. Has anyone encountered some literature or web pages dealing with this issue of non-technical violations of db model ?
Daniel Pokrývka
Is the "subjective" word a mantra here ? Sorry, I am indeed a newbie. But from my standpoint it is impossible for a human to be anything but subjective. Objectivity as a word never fullfiles its meaning.. and declaring the respect for other opinions before any own opinion is said is a nice example of self deceiveing that the objectivity exists.Although.. 'might you have a different opinion. I agree with you.'I know that the disscusion I desired is about different issue but I find the matter of subjectivity relativly attractive.
Daniel Pokrývka
@Daniel, "subjective" means you can't really have a definite right or wrong answer. While you can chose not to accept any answer, it is generally encouraged to accept answer OR tag it as a wiki.
o.k.w
OK, I accept your answer.
Daniel Pokrývka
@Daniel, do not accept answer for the sake of accepting. fyjham made some very good points too :)
o.k.w
yes, I agree .. that is why I have accepted first yours and when his emerged, I changed my mind and accepted his :-) Still, thanks for your concern.
Daniel Pokrývka
+2  A: 

We add columns to our tables that are referenced by a variety of apps all the time.

So long as the applications specifically reference the columns they want to use and you make sure the new fields are either nullable or have a sensible default defined so it doesn't interfere with inserts I don't see any real problem.

That said, if an app does a select * then proceeds to reference the columns by index rather than name you could produce issues in existing code. Personally I have confidence that nothing referencing our database does this because of our coding conventions (That and I suspect the code review process would lynch someone who tried it :P), but if you're not certain then there is at least some small risk to such a change.

In your actual scenario I'd go back to the contractor and give your reasons you don't think the change will cause any problems and ask the rationale behind their choice. Maybe they have some application-specific wisdom behind their suggestion, maybe just paranoia from dealing with other companies that change the database structure in ways that aren't backwards-compatible, or maybe it's just a policy at their company that got rubber-stamped long ago and nobody's challenged. Till you ask you never know.

Tim Schneider
Thanks for your suggestions. My impression is that a paranoia is behind .. but, it will be a subject of disscusion and I hope the issue can be cleared easily. I think the contractor tries to have a set o core tables, which will never change .. because we add new functionalities all the time and they are "country-specific", they want to have some base tables which are easy to understand in every country.I simply feel that their solution is shorthanded and not really systematic. But ... they have given a start to a discussion of a deeper issue by their small request.. which may prove useful.
Daniel Pokrývka
A: 

Very often, the programming community is unreasonably concerned about the ripple effect that results from redefining tables. Usually, this is a result of failure to understand data independence, and failure to guard the data independence of their operations on the data. Occasionally, the original database designer is at fault.

Most object oriented programmers understand encapsulation better than I do. But these same experts typically don't understand squat about data independence. And anyone who has learned how to operate on an SQL database, but never learned the concept of data independence is dangerously ignorant. The superficial aspects of data independence can be learned in about five minutes. But to really learn it takes time and effort.

Other responders have mentioned queries that use "select *". A select with a wildcard is more data dependent than the same select that lists the names of all the columns in the table. This is just one example among dozens.

The thing is, both data independence and encapsulation pursue the same goal: containing the unintended consequences of a change in the model.

Here's how to keep your IT chief happy. Define a new table with a new name that contains all the columns from the old table, and also all the additional columns that are now necessary. Create a view, with the same name as the old table, that contains precisely the same columns, and in the same order, that the old table had. Typically, this view will show all the rows in the old table, and the old PK will still guarantee uniqueness.

Once in a while, this will fail to meet all of the IT chief's needs. And if the IT chief is really saying "I don't understand databases; so don't change anything" then you are up the creek until the IT chief changes or gets changed.

Walter Mitty
Valuable answer, thank you. I will think about shaping the database in a way programmer finds logical and at the same time I can make the IT Chief happy using the views thus having the "core" tables unchanged in his eyes.
Daniel Pokrývka