|
Interesting Database Field
-
01-16-2008 6:14 PM
|
|
-
JeffS


- Joined on 12-31-2007
- near Cincinnati, USA
- Posts 16
|
Interesting Database Field
(So, this "Sidebar" is for WTFs that aren't front-page-worthy. I'm not sure what I'm posting here is even Sidebar-worthy... but I got a chuckle... maybe you will too.)
I found this gem of a field in a database table for storing users' names:
MiddleInitial NVARCHAR(255)
|
|
-
-
wgh


- Joined on 07-07-2006
- Posts 58
|
Re: Interesting Database Field
Made me snort == definitely sidebar worthy.
"You can't triple-stamp a double-stamp."
|
|
-
-
m0ffx


- Joined on 08-15-2006
- Posts 602
|
Re: Interesting Database Field
I rolled my eyes at first, but then I realised; the column's slightly misnamed. Were it MiddleInitials, then it makes sense, since people can have as many middle names as they like.
TRWTF is Community Server
|
|
-
-
Patricktamu


- Joined on 10-25-2007
- Posts 3
|
Re: Interesting Database Field
I think this is the datatype used when you import string data from excel. Maybe the table was first created from an excel import, and the designer missed changing the datatype for this column.
|
|
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
Re: Interesting Database Field
m0ffx:I rolled my eyes at first, but then I realised; the column's slightly misnamed. Were it MiddleInitials, then it makes sense, since people can have as many middle names as they like.
If you have 255 middle names then I am going to punch you in the snoot for being a pompous git.
|
|
-
-
Lingerance


- Joined on 07-24-2007
- Canada
- Posts 1,172
|
Re: Interesting Database Field
asuffield: m0ffx:I rolled my eyes at first, but then I realised; the column's slightly misnamed. Were it MiddleInitials, then it makes sense, since people can have as many middle names as they like.
If you have 255 middle names then I am going to punch you in the snoot for being a pompous git.
Actually, in most cases, it's the parents who don that absurd amount of middle names upon their child. So I would shoot the parents for being twits and giving their child hundreds of middle names.
irc://irc.slashnet.org/#TDWTF (Redirects to #CodeLove ) Yo dawg I herd hoard you like to search so I put a 2TB txt file in yo SSDS so your memory's maxed out and your computer cant do shit? -- Nyquist
|
|
-
-
femalegamer


- Joined on 05-01-2006
- Posts 1
|
Re: Interesting Database Field
We're having to deal with data from someone else's program, and one of their fields is a text field for ip address, which is 32 characters long. Yeah, sometimes people are just not thinking very well...
|
|
-
-
magetoo


- Joined on 11-08-2006
- Posts 90
|
Re: Interesting Database Field
Lingerance:So I would shoot the parents for being twits and giving their child hundreds of middle names.
No parents, and even more names?!?
|
|
-
-
henke37


- Joined on 05-22-2007
- Sweden
- Posts 155
|
Re: Interesting Database Field
Well, not everybody knows how to store them properly
|
|
-
-
ggeens


- Joined on 08-24-2007
- Posts 10
|
Re: Interesting Database Field
I think the person who created the table just selected a string datatype and forgot to adjust the length.
|
|
-
-
valerion


- Joined on 02-26-2007
- Posts 125
|
Re: Interesting Database Field
femalegamer:We're having to deal with data from someone else's program, and one of their fields is a text field for ip address, which is 32 characters long. Yeah, sometimes people are just not thinking very well...
Er, IPV6????
|
|
-
-
PJH


- Joined on 02-14-2007
- Newcastle, UK
- Posts 1,253
|
Re: Interesting Database Field
valerion: femalegamer:We're having to deal with data from someone else's program, and one of their fields is a text field for ip address, which is 32 characters long. Yeah, sometimes people are just not thinking very well...
Er, IPV6????
'Text field' would suggest 'human readable form' making 32 characters insufficient. To pluck an example address off Wikipedia: 2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
Abstinence makes the Church grow fondlers.
- unknown
|
|
-
|
|
Re: Interesting Database Field
That code is bad. It will be the first code against the wall when UCS-2048 comes.
|
|
-
-
magetoo


- Joined on 11-08-2006
- Posts 90
|
Re: Interesting Database Field
PJH:'Text field' would suggest 'human readable form' making 32 characters insufficient. To pluck an example address off Wikipedia: 2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
And exactly seven of them are colons.
|
|
-
-
magetoo


- Joined on 11-08-2006
- Posts 90
|
Re: Interesting Database Field
What the hell, I accidentally hit "quote" instead of "edit", and now I can't delete the resulting mess...
|
|
-
-
PJH


- Joined on 02-14-2007
- Newcastle, UK
- Posts 1,253
|
Re: Interesting Database Field
magetoo: PJH:'Text field' would suggest 'human readable form' making 32 characters insufficient. To pluck an example address off Wikipedia: 2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
And exactly seven of them are colons.
Removing them no longer produces a human readable address. Or are you suggesting complicating matters by removing them on insertion to the database, and adding them back in on extraction?
Abstinence makes the Church grow fondlers.
- unknown
|
|
-
-
magetoo


- Joined on 11-08-2006
- Posts 90
|
Re: Interesting Database Field
PJH: magetoo: PJH:2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
And exactly seven of them are colons.
Removing them no longer produces a human readable address. Or are you suggesting complicating matters by removing them on insertion to the database, and adding them back in on extraction?
Don't ask me, ask whoever decided the field should be 32 characters. I'm just saying that an IPv6 address would fit in there, whether you think it "suggests human readable" or not. (To me, the human readable format is "host.example.com" and nothing else.)
Of course making it, say, a nice even 40 characters would be better, to guard against all permutations.
|
|
-
-
belgariontheking


- Joined on 08-20-2007
- Cincinnati, OH, USA
- Posts 2,276
|
Re: Interesting Database Field
magetoo: PJH: magetoo: PJH:2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
And exactly seven of them are colons.
Removing them no longer produces a human readable address. Or are you suggesting complicating matters by removing them on insertion to the database, and adding them back in on extraction?
Don't ask me, ask whoever decided the field should be 32 characters. I'm just saying that an IPv6 address would fit in there, whether you think it "suggests human readable" or not. (To me, the human readable format is "host.example.com" and nothing else.) Of course making it, say, a nice even 40 characters would be better, to guard against all permutations.
It's best to put ip addresses into a binary representation in the database, because the translations to human-readable are trivial. IPv4 can do it with an unsigned int. (At least in MySQL), searching for values BETWEEN two numbers is highly optimized. But I bet you all already knew that. Considering that, I dunno why I said it.
SpectateSwamp exposing aliens. Obviously the World needs SSDS
[10:07] <fatdog> so from now on.. be sure to wear nice clean underwear [10:07] <mps> fatdog: That is simply not going to happen
|
|
-
-
caffeinatedbacon


- Joined on 09-23-2007
- Posts 8
|
Re: Interesting Database Field
magetoo:
PJH:
magetoo:
PJH:
2001:0db8:85a3:08d3:1319:8a2e:0370:7344 I count 39 characters there.
And exactly seven of them are colons.
Removing them no longer produces a human readable address.
Or are you suggesting complicating matters by removing them on insertion to the database, and adding them back in on extraction?
Don't ask me, ask whoever decided the field should be 32 characters. I'm just saying that an IPv6 address would fit in there, whether you think it "suggests human readable" or not. (To me, the human readable format is "host.example.com" and nothing else.)
Of course making it, say, a nice even 40 characters would be better, to guard against all permutations.
Since it's permissible to omit leading zeroes, and even collapse entire blocks of consecutive groups of zeroes in IPv6, can you please do me the honour of properly formatting this address?
23D4456EA67822
While adding the colons in an IPv6 address is unneccesary if you *require* all 32 digits to be included in a field such as this, it just may be worth the extra 7 bits to ensure that you're getting the full picture, all the time (since, by the rationale that this field may share IPv4 and IPv6 addresses, you never know how many digits you'd receive).
Your recommendation of going with a 40-char field would be a far-better solution.
/just sayin'
P.S. if you guessed 0002:03D4:456E:0000:0000:00A6:0782:0002, you win!
|
|
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
Re: Interesting Database Field
caffeinatedbacon:23D4456EA67822 P.S. if you guessed 0002:03D4:456E:0000:0000:00A6:0782:0002, you win!
No. It's ::0023:d445:6ea6:7822. ipv6 collapsed form is not ambiguous, any more than ipv4 collapsed form is.
|
|
-
-
caffeinatedbacon


- Joined on 09-23-2007
- Posts 8
|
Re: Interesting Database Field
asuffield:
caffeinatedbacon:
23D4456EA67822
P.S. if you guessed 0002:03D4:456E:0000:0000:00A6:0782:0002, you win!
No. It's ::0023:d445:6ea6:7822. ipv6 collapsed form is not ambiguous, any more than ipv4 collapsed form is.
Actually, you would be incorrect. You may collapse any leading zero in any group of four hexidecimal groups in IPv6, *as well as* any consecutive group of four zeroes (but only one set of consecutive groups of zeroes may be collapsed), so the example provided could be ::0023:d445:6ea6:7822 or it could be 0023:d445:6ea6:7822::, which of course, as you can see, are two vastly different addresses.
As for the specific case I was citing, please scroll up through the assumptions above.
femalegamer said that she was dealing with a 32-character field for an IP address. valerion replied "IPv6?", assuming that femalegamer hadn't considered the possibility that it was to house an IPv6 address PJH pointed out that a properly formatted IPv6 address features colons separating 16-bit groups magetoo seemed to think that 32 Characters were enough to handle an IPv6 address, which PJH rebutted magetoo again, stated that an IPv6 address would fit there, but that perhaps a 40 Char string would be better
In my post, I attempted to highlight that the only way you could accurately reflect an IP address in a field that mixed IPv4 & IPv6 addresses was with a field size that allowed the inclusion of all required seperators and humorously highlighting the challenge of re-inserting those seperators in a variable-length field; I agreed with magetoo's latter suggestion of instead making it a 40-character field (though 39 would do) to overcome that challenge. I made no mention in my post related to the (non)ambiguity of a *properly-formatted* collapsed-form IPv6 address, but did allude to the fact that a 32 character field would prohibit you, strictly-speaking, from properly formatting every possible IPv6 address received.
Regardless of the semantics in my post, or those previous, can you think of a valid reason to arbitrarily extended a 32-bit address to 32 characters, or restrict a 128-bit address with it's required seperators, to 32 characters? Would you seriously be willing to deal with the headache of programming countless exceptions for the sake of 7 bits/record?
In my part of the world, that does != success.
|
|
-
-
asuffield


- Joined on 05-31-2006
- Posts 2,137
|
Re: Interesting Database Field
caffeinatedbacon:so the example provided could be ::0023:d445:6ea6:7822 or it could be 0023:d445:6ea6:7822::
No. It's defined as being ::0023:d445:6ea6:7822. Bare numbers without colons build up from the low byte, just like ipv4 (where the address "16" is 0.0.0.16, not 16.0.0.0).
caffeinatedbacon:You may collapse any leading zero in any group of four hexidecimal groups in IPv6, *as well as* any consecutive group of four zeroes (but only one set of consecutive groups of zeroes may be collapsed)
If AND ONLY IF you are using colon notation, which you were not. Furthermore, any consecutive groups of zeroes may be collapsed only into ::, not into nothing.
You can't just make up your own ways to write addresses. There are very clearly defined rules for how ipv6 notation works.
|
|
-
-
caffeinatedbacon


- Joined on 09-23-2007
- Posts 8
|
Re: Interesting Database Field
asuffield:No. It's defined as being ::0023:d445:6ea6:7822. Bare numbers without colons build up from the low byte, just like ipv4 (where the address "16" is 0.0.0.16, not 16.0.0.0).
Bare numbers without colons do not build into anything. Building up from the low byte is not an acceptable addressing method specified in RFC 4291, bare numbers without colons are not properly formatted IPv6 addresses and should not be assumed to be anything. Case in point, what IP address does '45' represent (using your bare numbers can be assumed to build up from the low byte argument)? Is it an IPv4 decimal notation 45 (binary 00101101) or an IPv6 Hex 45 (1000101)? The whole point I was trying to make is that if you do not allow for a full, properly-formatted address in a field that assumes you're collecting mixed IP address data, you're capturing garbage.
asuffield:If AND ONLY IF you are using colon notation, which you were not. Furthermore, any consecutive groups of zeroes may be collapsed only into ::, not into nothing.
You can't just make up your own ways to write addresses. There are very clearly defined rules for how ipv6 notation works.
No kidding. Well I guess I've clearly been schooled.
Dude, go back and read my last post, take a breath, and get a life.
|
|
-
-
MasterPlanSoftware


- Joined on 11-10-2006
- Posts 108
|
Re: Interesting Database Field
caffeinatedbacon: asuffield:No. It's defined as being ::0023:d445:6ea6:7822. Bare numbers without colons build up from the low byte, just like ipv4 (where the address "16" is 0.0.0.16, not 16.0.0.0).
Bare numbers without colons do not build into anything. Building up from the low byte is not an acceptable addressing method specified in RFC 4291, bare numbers without colons are not properly formatted IPv6 addresses and should not be assumed to be anything. Case in point, what IP address does '45' represent (using your bare numbers can be assumed to build up from the low byte argument)? Is it an IPv4 decimal notation 45 (binary 00101101) or an IPv6 Hex 45 (1000101)? The whole point I was trying to make is that if you do not allow for a full, properly-formatted address in a field that assumes you're collecting mixed IP address data, you're capturing garbage.
asuffield:If AND ONLY IF you are using colon notation, which you were not. Furthermore, any consecutive groups of zeroes may be collapsed only into ::, not into nothing.
You can't just make up your own ways to write addresses. There are very clearly defined rules for how ipv6 notation works.
No kidding. Well I guess I've clearly been schooled.
Dude, go back and read my last post, take a breath, and get a life.
Use the tag, Luke.
|
|
-
-
caffeinatedbacon


- Joined on 09-23-2007
- Posts 8
|
Re: Interesting Database Field
MasterPlanSoftware:
LOL, I'm a long-time reader of TDWTF, but don't spend a lot of time in the forums so until now, hadn't had the joy of meeting asuffield; I've now read a pile of his posts thanks to that tag and have to admit, he seems quite brillant!
Thanks, MasterPlanSoftware, it's nice to have have someone bring some sense to a thread. Cheers!
|
|
-
-
magetoo


- Joined on 11-08-2006
- Posts 90
|
Re: Interesting Database Field
Apologies for the grave digging, but since it was adressed (ha!) to me...
caffeinatedbacon:
Since it's permissible to omit leading zeroes, and even collapse entire blocks of consecutive groups of zeroes in IPv6, can you please do me the honour of properly formatting this address?
23D4456EA67822
Ahem...
Building up from the low byte is not an acceptable addressing method specified in RFC 4291, bare numbers without colons are not properly formatted IPv6 addresses and should not be assumed to be anything.
(emphasis mine)
I suppose the answer to your request would be "that's not a valid address", then.
P.S. if you guessed 0002:03D4:456E:0000:0000:00A6:0782:0002, you win!
And I'd also suggest that 000203D4456E0000000000A607820002 really does fit in a 32-character field, even if it's pretty stupid to do it that way.
|
|
-
-
caffeinatedbacon


- Joined on 09-23-2007
- Posts 8
|
Re: Interesting Database Field
magetoo:Apologies for the grave digging, but since it was addressed (ha!) to me...
I think it's only fair :)
caffeinatedbacon:Since it's permissible to omit leading zeroes, and even collapse entire blocks of consecutive groups of zeroes in IPv6, can you please do me the honour of properly formatting this address?
23D4456EA67822
OK, granted it was a pretty fuzzy/crappy way of explaining my point, but this is what I was thinking when I tried to capture problems that could arise with that particular field length:
An unsuspecting user loads a DB with IP's from a CSV file. The IP field has properly-formatted IPv6 addresses (with leading zeroes and consecutive zero word-groups collapsed) The user tries to copy full addresses that exceed 32 chars and hit errors at that point
The user has two options at this point: either do a considerable amount of clean-up in their source data (since they can't just do a simple search and replace of colons with zeroes), or contact someone in dev so they can change the field length on the IP address field. If it were you or me and the field size was really that important, we would do some programming to automate the data clean-up, but for the guy making $12/hr whose job it is to load the data, that task may not be so trivial. In my worst case scenario, I imagined that the data-entry guy would do what was most expedient for him which would be to simply search and replace ":" with "", thereby tucking everything to 32 chars or less, solving his problem but creating a hidden disaster for future DB users.
So you know, I really wasn't trying to pick on your post, especially since you were just offering a possible path of reasoning in the twisted mind of some other anonymous programmer, and who knows, maybe that's what he was thinking (or it could be something as stupid as someone telling him one time that an IPv4 address is 32 bits... and everyone knows that 32 bits = 32 chars, right? ;) I was just trying to offer a view as to why 32 chars really isn't a great solution for containing IPv6 addresses (which you seem to agree with as well).
Anyway, I hope we can all be friends and carry on (this thread is giving me indigestion ;)
Cheers!
|
|
Page 1 of 1 (27 items)
|
|
|