On 10/28/2017 12:48 AM, mbsoftwaresolutions@mbsoftwaresolutions.com wrote:
The OCD part of me wants to define the smallest type possible, whereas the "let's set it and never worry about it" part of me says "just make everything INT."
I like to leave wiggle room generally. But really, using 2, 4, 8, or even 16 bytes is minimal impacts in my experience. So, for example, if you expect the number to never be over a million, I'd probably use Int - which gives up to 2 billion. If you're sure it will never go over 255, I'd still probably go with the 4 byte size.
Maybe you could squeeze that if you know regular maintenance could be done to "reset" values (if feasible). But then, if your system might be integrated with others, ids should usually NEVER be reset.
Whatever the case, please don't do something idiotic like declare "VARCHAR(4000)" for fields that will never have more than 20 characters. That's the most common, stupid, wasteful, inefficient mistake I've seen in so-called "enterprise" apps.
-Charlie