![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
| Hi all, I was shown a table (AccountHistory) structure today which looked like this. Ac_ID Transaction_Date CR DB 1 02/01/2003 100 0 1 03/01/2003 320 0 2 03/01/2003 500 0 2 04/02/2003 0 250 CR and DB are Credit and Debit. I didn't like this idea, and thought that the table would be better like this (probably with a Tr_ID primary key as well). Ac_ID Tr_Date Tr_Month Tr_Type Amount 1 02/01/2003 1 CR 100 1 03/01/2003 1 CR 320 2 03/01/2003 1 CR 500 2 04/02/2003 2 DB 250 However, the person who uses the first structure says it facilitates his reports, and certainly, on first glance it seems to me that this is true - he wants reports in the form Title =================== Account ID: XXXXXXXXX Account Name XXXXXXXXX ================== /// Report rows Month Total DB Total CR NetBalance 1 1000 500 500 DB 2 3000 1500 1500 DB 3 1000 600 500 DB ...etc. Could anyone explain to me: a) what is wrong with the first table structure? b) if (and how) the second one is better)? and finally, c) how to get the result wanted from the second table structure? Paul... p.s. I have noticed in the past that some questions similar to this get a "tell your professor to fail you" - this is not an assignment - I'm actully trying to help somebody else out on the borland.public.interbase.sql newsgroup - see the recent "Complex SQL statment question" thread, but am not 100% sure of my theorectical ground, and I would appreciate explanations, references, URL's, debates, discussions, ideas, rants and raves from knowledgeable people who are interested in helping people out on this group. -- plinehan__AT__yahoo__DOT__com C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04 W2K Pro Please do not top-post. |
#3
| |||
| |||
|
| Hi all, I was shown a table (AccountHistory) structure today which looked like this. Ac_ID Transaction_Date CR DB 1 02/01/2003 100 0 1 03/01/2003 320 0 2 03/01/2003 500 0 2 04/02/2003 0 250 CR and DB are Credit and Debit. I didn't like this idea, and thought that the table would be better like this (probably with a Tr_ID primary key as well). Ac_ID Tr_Date Tr_Month Tr_Type Amount 1 02/01/2003 1 CR 100 1 03/01/2003 1 CR 320 2 03/01/2003 1 CR 500 2 04/02/2003 2 DB 250 However, the person who uses the first structure says it facilitates his reports, and certainly, on first glance it seems to me that this is true - he wants reports in the form Title =================== Account ID: XXXXXXXXX Account Name XXXXXXXXX ================== /// Report rows Month Total DB Total CR NetBalance 1 1000 500 500 DB 2 3000 1500 1500 DB 3 1000 600 500 DB ...etc. Could anyone explain to me: a) what is wrong with the first table structure? b) if (and how) the second one is better)? and finally, c) how to get the result wanted from the second table structure? Paul... p.s. I have noticed in the past that some questions similar to this get a "tell your professor to fail you" - this is not an assignment - I'm actully trying to help somebody else out on the borland.public.interbase.sql newsgroup - see the recent "Complex SQL statment question" thread, but am not 100% sure of my theorectical ground, and I would appreciate explanations, references, URL's, debates, discussions, ideas, rants and raves from knowledgeable people who are interested in helping people out on this group. -- plinehan__AT__yahoo__DOT__com C++ Builder 5 SP1, Interbase 6.0.1.6 IBX 5.04 W2K Pro Please do not top-post. |
#4
| |||
| |||
|
|
Could anyone explain to me: |
#5
| |||
| |||
|
|
b) if (and how) the second one is better)? It is in a proper domain key normal form (DKNF); he needs a constraint to enforce his model. |
|
c) how to get the result wanted from the second table structure? SELECT ... SUM(CASE WHEN posting = 'CD' THEM amt ELSE 0.00 END) AS tot_cd, |
#6
| |||
| |||
|
|
2) The table structure proposed by me was like this: ----------------------------------------------- Ac_ID Tr_Date Tr_Month Tr_Type Amount 1 02/01/2003 1 CR 100 1 03/01/2003 1 CR 320 2 03/01/2003 1 CR 500 ----------------------------------------------- Is there not a problem in the fact that the column Tr_Month contains data which is already present in the column Tr_Date, and therefore that introduces a redundancy and hence the table is not properly normalised? [ snip ] |
#7
| ||||
| ||||
|
|
I presume that by "constraint to enforce his model" you mean a primary key of some sort - i.e. there should be a Transaction_ID field |
|
2) The table structure proposed by me was like this: |
|
Is there not a problem in the fact that the column Tr_Month contains data which is already present in the column Tr_Date, and |
|
I know from my travels on the internet that you have given courses in how to denormalise tables - is this a "real world" situation where |
![]() |
| Thread Tools | |
| Display Modes | |
| |