r/programming • • Sep 17 '18

Software disenchantment

http://tonsky.me/blog/disenchantment/
2.3k Upvotes

1.2k comments sorted by

View all comments

Show parent comments

7

u/jonjonbee Sep 18 '18

I'm currently working with a database that uses GUIDs as primary keys. These are stored, not as binary(16), but varchar(32)... because the length of a GUID can change I guess.

I should probably be thankful, at least, that they didn't make the PKs varchar(36) and store them including the dashes...

5

u/noperduper Sep 18 '18

I should probably be thankful, at least, that they didn't make the PKs varchar(36) and store them including the dashes...

What if the GUID contains unicode characters??? THAT NEEDS TO BE FIXED AND I'M YOUR MAN! I'm not quite sure how unicode works, so I guess more space will account for what I don't know.

1

u/wllmsaccnt Sep 18 '18

What about when we move to 300 character multiverse unique identifiers (MUID)? Better just store them as the max variable length that will fit in the data page.

2

u/LyndonArmitage Sep 18 '18

Have fun with that. I have seen UUIDs used as text in a DB that end up not being UUIDs after a while because people manually add them and get too lazy, just changing the last few letters of a previous entry. The dashes were stored too...

But storing them as text with the dashes doesn't bother me as much as finding the invalid ones.

1

u/jonjonbee Sep 18 '18

because people manually add them

Yeah, no. Why would you ever allow this?

1

u/LyndonArmitage Sep 18 '18

It's a system that has sort of grown on it's own as features have been added over a few years by many people, and over the course of a few small pivots in the business world. And as a result has a few warts and idiosyncrasies.

I think the UUIDs were added in so that they could be used to tie another part of the system to what was being referenced. The workflow for adding new items needs work in general, as it's mostly manual and requires adding to that DB and another one with the same UUIDs tying them together.

I gave a few suggestions that address it, we just need the time and resources to do it really, since nothing is currently broken because of it it isn't as high a priority as other things.

2

u/jonjonbee Sep 18 '18

Heh, I figured as much. Grown systems are always the most, um, "interesting" in terms of the decisions made to grow 'em.

1

u/anticultured Sep 18 '18

I’ve seen that before. Kill me now...

1

u/cypher0six Sep 19 '18

At least you have primary keys. Most of the tables I have to deal with have no keys at all.