• kevincox@lemmy.ml
    link
    fedilink
    arrow-up
    17
    ·
    5 months ago

    It is true, don’t do it.

    Even at huge companies like Google, lots of stuff was keyed on your email address. This was a huge problem so Google employees were not allowed to change their email for the longest time. Eventually they opened it up by request but they made it very clear that you would run into problems. So many systems and services would break. Over time I think most external services are pretty robust now, but lots of internal systems still use emails (or the username part of it) and have issues.

    IIUC Google accounts now use a random number as the key. But there are still places where the email is in use, slowly being fixed at massive cost.

      • kevincox@lemmy.ml
        link
        fedilink
        arrow-up
        1
        ·
        5 months ago

        I don’t think that is true. Not much at Google really bought into the UUID hype. At least not for internal interfaces. But really there is no difference between a UUID v4 and a large random number. UUID just specifies a standard formatting.

  • BrianTheeBiscuiteer@lemmy.world
    link
    fedilink
    arrow-up
    16
    ·
    5 months ago

    Got hands on experience with this. Wasn’t my design choice but I inherited an app with a database where one of the keys was tied to a completely separate database. I mean at the time it probably made sense but the most unlikely of scenarios actually happened: that other database, the one I had zero control over, was migrated to a new platform. All of those keys were synthetic so of course they were like, “Meh, why we gotta keep the old keys?” So post-migration my app becomes basically useless and I spent 6 hours writing migration code, some of it on off hours, to fix my data.

    So it’s questionable whether a foreign key of a completely different system is a natural key, but at the very least never use a key YOU don’t control.

    • state_electrician@discuss.tchncs.de
      link
      fedilink
      arrow-up
      1
      arrow-down
      6
      ·
      5 months ago

      I don’t think that holds true in all scenarios. You need to use a key that has some guarantees. In many systems you will use data you don’t control, like email addresses, IBANs, ISBNs, passport IDs and many more. You have zero control over those keys, but because each comes with certain guarantees, they might be suitable as a foreign key in your context.

      • Kissaki@programming.dev
        link
        fedilink
        English
        arrow-up
        10
        ·
        5 months ago

        People regularly change email addresses. Listing that as an example is a particularly bad example in my opinion.

          • smaximov@lemmy.world
            link
            fedilink
            arrow-up
            6
            ·
            5 months ago

            Well, I use the same self hosted Email address since the late 80‘s

            Personal anecdotes are rarely pose a valid argument (unless you are designing a database specifically for users who use the same email address since the late 80’s).

          • Kissaki@programming.dev
            link
            fedilink
            English
            arrow-up
            2
            ·
            5 months ago

            Ignoring secondary email addresses, what was my primary [onlineaccount] E-Mail address has changed four times.

      • BrianTheeBiscuiteer@lemmy.world
        link
        fedilink
        arrow-up
        6
        ·
        5 months ago

        Even in this scenario it’s feasible for standards to change. ISBN-15 becomes a thing and suddenly you have books that never get an ISBN-13 so your primary key constraints cause an error for trying to insert a null. Granted, you can see a lot of these changes coming but again, they come on a schedule you don’t control.

      • Eager Eagle@lemmy.world
        link
        fedilink
        English
        arrow-up
        4
        ·
        edit-2
        5 months ago

        These things can just be unique fields. I think the takeaway here is exactly to not use these unique fields as database keys if you have the option / if it’s up to you.

  • magic_lobster_party@kbin.run
    link
    fedilink
    arrow-up
    7
    arrow-down
    1
    ·
    5 months ago

    This is tied to YAGNI. Do you really need to impose this restriction on this database? Don’t add restrictions “just in case it might be useful”. If you don’t have a good reason, you ain’t gonna need it.

      • Corbin@programming.dev
        link
        fedilink
        English
        arrow-up
        4
        ·
        5 months ago

        I think they’re saying that e.g. you shouldn’t index a natural key unless you know that you’re going to search/collate by that key as a column. Telling the database that a certain column contains (a component of) the primary key is adding a restriction to that column.

  • Aux@lemmy.world
    link
    fedilink
    arrow-up
    6
    arrow-down
    2
    ·
    5 months ago

    I didn’t even know that natural keys exist. Who is using them and why?

  • Skydancer@pawb.social
    link
    fedilink
    arrow-up
    21
    arrow-down
    19
    ·
    5 months ago

    A well argued point. Could have done without the random transphobic comments about “transsexuals” and “perceived gender”.

    • Womble@lemmy.world
      link
      fedilink
      English
      arrow-up
      20
      arrow-down
      2
      ·
      5 months ago

      The author is Danish, are you so certain that this isnt just slightly awkward usage of a second laguage that you are willing to throw transphobic at them as an insult?

      • Skydancer@pawb.social
        link
        fedilink
        arrow-up
        9
        arrow-down
        2
        ·
        5 months ago

        No - it was the language that I said was transphobic, not the author. Given that there were two different word choices (“transsexual” and “perceived gender”) that reinforced each other, it seems more likely than not that they reflected the mindset of the author, but not having looked further for their other writings I was not sure. That’s why I said " transphobic language" and not “transphobic author”.

    • AwesomeLowlander@lemmy.dbzer0.com
      link
      fedilink
      arrow-up
      20
      arrow-down
      4
      ·
      5 months ago

      Agreed with the other commenter, there’s no real reason to think the author’s transphobic due to a random phrase. We as a society really need to stop organising witch hunts.

      • Skydancer@pawb.social
        link
        fedilink
        arrow-up
        13
        arrow-down
        3
        ·
        edit-2
        5 months ago

        There’s nothing wrong with the example in and of itself, but the word “transsexual” in place of “transgender” is not generally random. It is explicitly chosen by Trans-Exclusionary Radical Feminists (TERFs) as well as by right-wing transphobes as a dog whistle to conflate gender dysphoria with drag queens and cross-dess fetishists so as to delegitimise transpeople and suggest some sort of sexual deviance. Coupled with the equivocation of “perceived” gender, motive doesn’t even have to come into it. The words themselves and the concepts they reinforce are transphobic and harmful.

        A witch hunt would have been for me to say that the author is a transphobic asshole whose writings need to be wiped from the internet - which is very far from what I actually posted, which was regret for the way the language they chose distracted from the flow of their argument by reinforcing the social stigmatization of trans people. (Edit: That was a deliberate choice on my part. Not knowing enough about the author to be sure of motives and having no desire to deep dive into their history, I decided that it was only appropriate to point out the hurtful nature of the language and not imply motive.)

        • AwesomeLowlander@lemmy.dbzer0.com
          link
          fedilink
          arrow-up
          9
          arrow-down
          1
          ·
          5 months ago

          It is explicitly chosen by Trans-Exclusionary Radical Feminists (TERFs) as well as by right-wing transphobes

          It can also be used by people with no agenda, including most of the non-western world. Language policing is ridiculous. You want to cancel the transphobes? Stop giving them power and reclaim their terms from them.

        • TehPers@beehaw.org
          link
          fedilink
          English
          arrow-up
          5
          arrow-down
          1
          ·
          5 months ago

          Speaking as someone with a MTF close friend and NB spouse, but the term used in the article is the term everyone around me used when I was growing up. That term may be obsolete now, and if so, the author simply needs to be informed. There’s no need to assume they meant harm by it.

          If they knowingly used a term that may offend, then that’s of course a separate issue.

      • Reddfugee42@lemmy.world
        link
        fedilink
        arrow-up
        4
        arrow-down
        6
        ·
        5 months ago

        We as a society really need to stop organising witch hunts.

        Yeah, we’re way too hard on bigots

    • Redkey@programming.dev
      link
      fedilink
      arrow-up
      7
      ·
      5 months ago

      I think I can appreciate where you’re coming from, but in the context of the article it was legitimately necessary to address the topic somehow; it’s not like it was written apropos of nothing as a commentary on transsexuality. As a CIS person, I also have a “percieved gender” with which I identify.

      Would “post-transition gender” be a more sensitive term, or less?

      • Skydancer@pawb.social
        link
        fedilink
        arrow-up
        8
        arrow-down
        1
        ·
        5 months ago

        More, but there’s an even simpler solution. In the context, the author is distinguishing between “sex assigned at birth” and “perceived gender.” The equivocating word " perceived" could simply be dropped with no loss of clarity.