Subject | RE: [firebird-support] "best way" of doing a very simple thing (or is "expensive" having fields with nulls?) |
---|---|
Author | Leyne, Sean |
Post date | 2013-11-19T00:02:13Z |
> I have a simple table like thisIt depends:-]
>
> CREATE TABLE INVOICES_DETAIL (
> ID ID,
> ID_STOCK FK_ID,
> QTY INTEGER,
> PRICE MONEY,
> DEFAULT_PRICE MONEY
> );
>
> Most of the times, (lets say 90%) the default_price is null.
>
> It makes sence to use a field for that value?
> Or is better having an extra table and just add a record when the price is not
> null and then selecting the data with a left join to the secondary table?
Would a Default_Price = $0 have a special meaning? (mean that there is no default)
Personally, I see the cost of the extra column to be exponentially cheaper than using an extra table .
Further, I hate NULL in money type fields (I have a process with auto-creates triggers to ensure that money domain fields/columns assigns zero to the field).
Sean