3 ms·
Some of the more surprising ones (to me): 1) Don't use timestamp (without time zone) 2) Don't use varchar(n) by default - just use varchar or text without any
by chadash 7y ago
Some of the more surprising ones (to me):
1) Don't use timestamp (without time zone)
2) Don't use varchar(n) by default - just use varchar or text without any length specified
3) Don't use money - The money data type isn't actually very good for storing monetary values. Numeric, or (rarely) integer may be better.
- chopin 7y agoThe money one is a bit worrying, at least if "numerical" includes floating point types. It's almost never a good idea to use these for monetary values. If you are going to have different currencies I almost always would go for integer types (I don't understand the "rarely" advice here) as the fraction may vary greatly for different currencies. It's better to derive the fractional from the currency.
- colanderman 7y ago`numeric` is a decimal type with an optional fixed-precision mode, so it works fine with decimal currencies.
- masklinn 7y ago> 1) Don't use timestamp (without time zone) The problem with this one is both timestamp and timestamptz are problematic: * timestamp will implicitly discard input timezone information * timetamptz doesn't store a timezone, it converts everything to UTC and stores that; furthermore it assumes any data without timezone information is in the "timezone" system parameter and converts from that on input and to that on output Storing everything as UTC is problematic because it's completely unreliable for all future events e.g. it's plain broken for calendaring and reminders.