5

We complain a lot about others. I'll toss out my own dork up from today.

Customer: "Can we add more than X widgets? There seems to be a limit."

Me: "Wut? Lol no I didn't limit.... wait a second."

SQL... field type... varchar

-hand to forehead-

Comments
  • 4
    A varchar field... limits the _amount_ of widgets... what?
  • 0
    @alexbrooklyn It's where I store the widgets that they can add ... but varchar is limited to 255 characters, I kinda forgot about that.
  • 1
    @N00bPancakes is it a long string of widget names or ids?
  • 4
  • 0
    @alexbrooklyn widget names in this case. Even ids wouldn't save a lot of space as the "names" are pretty short / nonsensical.
  • 3
    @N00bPancakes I would've probably gone with a widget tables and a ma y-to-many table for users and widgets.

    But I'm sure that approach has more disadvantages compared to the textfield
  • 1
    @alexbrooklyn I hope that was sarcasm.
  • 0
    @IntrusionCM The first or second paragraph
  • 1
    @alexbrooklyn Last *sad puppy eyes*

    What ist love... Don't hurt me....
  • 3
    I’d also use a many:many relation.
    Space is cheap, especially for a table with three int columns! 😂

    Depending on implementation that’s 12 bytes (plus db overhead) per row/widget. Fair, the join would take a few more ms, but that’s really just moving the load from your app (string splitting) to the database, which is probably faster anyway.
  • 0
    @IntrusionCM I was trying to not be too judgemental or without context for once

    If I had to review it tho, I'd have killed the guy and forced the many-to-many approach
  • 1
    It's an denormalization...

    And one of the most dangerous.

    Storing multiple references in one field in a referential database leads to all kinds of fuckity - since now the handling of uniqueness, data integrity and so in lies on the application side.

    I've had to migrate similar problems and it usually ended with writing a parsing program...

    In the worst case, I had to play whack a mole and generate an XLS which some very unlucky coworkers had to double check manually - since the reference in the varchar was sometimes cut off, sometimes duplicated, sometimes pointing to null....

    Fun. Not.
  • 0
    To be clear the widget names are the primary key / ID of something else in the DB.

    I was being very vague as the story wasn't intending to go through the whole process here ;)

    I call them widget names because that is the end result for the user...
  • 1
    Come on, everyone! Let’s not all roast him over something he admitted was bad! That’s just mean.
  • 2
    @Root Thank you.

    I don't want to get into mega corp 5000's choices are bad / how they came to such decisions.

    Sometimes you work within the system before you can change how they do things.

    Also you pick longer fields....
Add Comment