Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Design Consideration for Number Column

Re: Design Consideration for Number Column

From: Jim Kennedy <kennedy-downwithspammersfamily_at_attbi.net>
Date: Sat, 2 Apr 2005 07:17:04 -0800
Message-ID: <wpednfPASKs2KtPfRVn-jg@comcast.com>

"dd" <dd_at_dd.com> wrote in message news:424e6fc6$1_1_at_rain.i-cable.com...
> Hi Jim,
>
> But what is your rationale behind this decision? NUMBER and NUMBER(8,2)
can
> both represents '489.49' . So why bother adding the constraint?
>
> Just like when programming java or C, we would use int or long for numeric
> values even as simple as a loop counter. We won't bother restricting the
> max value of our variable.
>
> Thx for any input
>
> "Jim Kennedy" <kennedy-downwithspammersfamily_at_attbi.net> bl
> news:VsGdnYCVfuNRhNPfRVn-gg_at_comcast.com g...
> >
> > "dd" <dd_at_dd.com> wrote in message news:424d7051$1_2_at_rain.i-cable.com...
> > > Is it a good design to use NUMBER for all numeric columns (vs specific
> > > precision, say, NUMBER(8,2))? Is there any real benefit to specify a
> > > precision ?
> > >
> > > I have this problem because Donald Bales in his book Java Programming
> with
> > > JDBC, Oreilly (chap 10.2) does recommend us defining both Integer and
> > > floating point values as NUMBER. I am not sure if JDBC type mapping
is
> a
> > > reason for his recommendation.
> > >
> > > Thx for any advice
> > >
> > >
> > I would use whatever precision is appropriate for your business needs.
(eg
> > if you are storing monetary values then perhaps 2 decimal places is
> correct.
> > if you are storing the number of items in an order then 0 decimal places
> is
> > correct. and so forth) Use it as a constraint on what the numbers
should
> > be.
> > Jim
> >
> >
>
>

To prevent people from adding wrong numbers. For example, if the system was one that tracked items ordered. If you have a table orders with a quantity column and if you can't order a fractional part then number(X,0) would be correct. Why? To prevent someone from putting in the wrong data according to the business rules. If you were storing stock prices then you might want 3 or 4 decimal places. Use the constraint as your business rules dictate. You don't want data outside your business rules. If you don't have a constraint then the data will get entered unconstrained. Jim Received on Sat Apr 02 2005 - 09:17:04 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US