views:

28

answers:

2

I have to design a database to handle forms.

Basically, a form needs to go through (exactly) 7 people, one by one. Each person can either agree or decline a form.
If one declines, the chain stops and the following people don't even get notified that there is a form.

Right now I have thought of those 3 tables: FORM, PERSON, and RESPONSE inbetween. However, my first solution sounds too heavy because each form could have up to 7 responses.

v1
Here we are with the table inbetween. That means that each successful form has 7 rows in the table RESPONSE.

v2
Here we have the responding information directly inside the form. It looks ugly but at least keeps everything as singular as possible. On the bad side I can't track the response dates, but I don't think it is crucial for that matter.

What is your opinion on this? I feel like both of them are wrong and I don't know how to fix that.
If that matters, I'll be using Oracle 9.

+3  A: 

Of the two, I'd advocate the first option, as it would be more flexible should the business process change, and require (say) 9 responses

If you're worried about storage, I would expect on average it to take less space to store "up to" 7 copies of the smaller form, than a single copy of the larger form.

Rowland Shaw
+1 Some people would say the second option isn't even in first normal form (no repeating groups). While that isn't strictly true, any table with columns xxx1, xxx2, ... xxxn is usually a sign of poor database design.
Tony Andrews
I did this in a rush. Strictly, the names are different, like Manager, Head of Service, Finance, Chief, HR contact, etc. It is all part of some kind of hierarchy, which is why the form has to be approved one by one, the last person being the "big boss of them all".
SK.
Fair enough, and that isn't so unreasonable up to a point, as the columns now have different meanings. It still lacks flexibility though, e.g. if in the future the company decides to drop HR Contact from, or add Marketing Manager to, the list of approvers.
Tony Andrews
Yeah, I agree. They did tell me it would defenately not change in the future, but that's something difficult to thrust from a programmer's point of view and I agree that the 2nd one is not open to that at all.
SK.
+2  A: 

First solution seems better. THen you can check if it is dissaproved by someone by doing simple SQL: ...WHERE response.isapproved=False. Otherwise you have to check all 7 fields in main table.

Riho
+1 Also imagine the query for "Show all forms that have been approved by Joe this month"!
Tony Andrews