Reputation: 3944
Perhaps someone with more experience in SQL Server can be of assistance. I am in the middle of putting together the LookUp tables for a new project. For 2 different tests that a user can perform (Bacteria/Fungi) the results are currently recorded on paper as the following:
BACTERIA: Bacteria cfu / ml
FUNGI: Fungi (yeast & mold) cfu /ml
<100
10^2
10^3
10^4
10^5
What would be the best way to capture these values in SQL Server 2008 R2? In particular, Data Type and Size?
Upvotes: 3
Views: 1280
Reputation: 5646
Something like this would probably be good enough:
CREATE TABLE AmountLookup (
UnitsLimitExp int NULL,
Name nvarchar(10) NULL
)
INSERT INTO AmountLookup
SELECT 2, '<100'
UNION ALL SELECT 3, '10^3'
UNION ALL SELECT 4, '10^4'
UNION ALL SELECT 5, '10^5'
UNION ALL SELECT 6, '10^6'
UNION ALL SELECT 7, '10^7'
This way you store the exponent, not the amount. Real value is just a GUI representation. Another thing is your lookup name, which is ugly here (10^3). However, you can store HTML code and treat it as raw HTML on your user interface, e.g. 104 is 10<sup>4</sup>
.
Upvotes: 1
Reputation: 238116
I'd propose a varchar(50)
:
Upvotes: 0
Reputation: 74390
If these are value and not ranges, INT
will work. If you start to deal with values greater than 2 billion, BIGINT
should be used. If you need decimal digits, you can use the DECIMAL
(NUMERIC
) type.
Your other option, since these are discrete values, is to use a lookup table for the values, whose surrogate key id you can use in the tables that hold references to the data. That way you can represent a concept such as "<100" .
Upvotes: 0