Subject | RE: [firebird-support] Re: Triggers to automagically add/modify/delete data in another table ? |
---|---|
Author | Alan McDonald |
Post date | 2006-05-09T07:43:06Z |
> > Adam, Alan,to get account balances:
> >
> > >If TableB contains some other fields, then I can understand the
> > >structure. If however there are no other fields aside from the
> > >FIELDID in tableB, then I don't know what is achieved by creating the
> > >table in the first place.
> >
> > >Normalisation 101: Duplicated data is often a sign that the database
> > >structure needs to be normalised.
> >
> > In effect is tableA that contains more data (columns).
> > TableB contains the same data of TableA but not ALL the data.
> > As said and simplifing the structure (that obviously is more complex):
> >
> > TableA
> > FieldID FieldA FieldB FieldC
> >
> > TableB
> > FieldID FieldA(the same of tableA) FieldC(the same of tableA)
> > It does not contains FieldB
> >
> > At this point It would be correct to create (for normalisation
> > database) one
> > only table and leave blank FieldB when not necessary (for the
> contability
> > movement of tableB that do not need it) ?
>
> absolutely! - that's what it's all about - make a CHAR(2) field
> if you like
> which contains 'CR' or 'DB' for the type of transaction
> Alan
SELECT USERID, SUM(CR-DB) FROM TABLEA GROUP BY USERID
then you will start thinking about rolling data over, i.e. at year end, post
a balancing credit or debit for the userid, move the data to a history table
and start over..
Alan
>
> >
> > Thank you very much for your help
> > Adriano