6 ms·
Please don't use the username as your primary key for a user! Usernames change. If your username can't change, you designed your system wrong. Systems that ar
by eridius 7y ago
Please don't use the username as your primary key for a user!
Usernames change. If your username can't change, you designed your system wrong.
Systems that are heavily persisted-comment-based at least have the excuse where changing a username would invalidate old comments referencing that user, but even GitHub still lets you change your username (if you link @-references to users, please store the user's ID in the backend text and only convert it back to a username when displaying; GitHub doesn't take this step but it should).
P.S. Hacker News, I'm looking at you.
- Topgamer7 7y agoIf you have strong foreign key constraints you should be able to update the record and let the changes cascade to each affected table.
- logicallee 7y agoCome on, user names don't change. Whether it's Hacker News (as you mention), a reddit username, a skype ID, or your gmail address, nobody expects the "username" to change, it is unique and can't be used if already taken, and everybody uses it as a unique ID on millions of websites without any issue. In fact, I can't name a single service I've ever used (ever!) that lets me change my username.
- scrollaway 7y ago> In fact, I can't name a single service I've ever used (ever!) that lets me change my username. Facebook? Twitter? Instagram? Any of the phone-number-based social apps (which have a poorer UX because of it, but still all allow changing usernames seeing as phone numbers change)? Also I believe Skype does allow changing usernames.
- logicallee 7y agoyou mention Facebook but isn't it just your display name that you can change? your username (the page listed under "username" if you tap your face in the Messenger app, or on the desktop web app, the page you're at if you click your icon with your name next to the search bar) doesn't change, does it? (maybe I'm wrong and it does.)
- eridius 7y agoFacebook lets you configure both your Name (display name) and Username (the URL slug for your profile) separately. You can even edit your Username right from within Messenger if you want.
- logicallee 7y agook, didn't know this.
- zaphirplane 7y agoHotmail Gmail Seriously why can’t people change their email and keep the mailbox. It’s not uncommon to pick a cute or funny email when you are a teen and want To change when you’ve all grown up
- im3w1l 7y agoWith an imap client you should be able to download emails from the old accounts and upload them on the new one.
- whammywon 7y agoXbox Live lets you change your gamertag, and I believe PSN does as well. Pretty sure you have to pay to do it, but there are definitely services that let you change your user name.
- lpghatguy 7y agoUsernames changing is important in a world where peoples' identities change. People transition and might not want a username based on their deadname. People get married or divorced and change their legal name, which can have ramifications on their usernames. People might just get older, and lose significance of old pseudonyms.
- logicallee 7y agodo you think hackernews should allow people to change their username?
- Groxx 7y agoif throwaway346392834 wants to become their normal username, sure. why not. of course it can be used for abuse - so show the old values next to it / on their user page / etc. allow N changes / limit the frequency. etc.
- logicallee 7y ago>so show the old values next to it this would remove one of the reasons cited: "People transition and might not want a username based on their deadname." (People go to great lengths to remove references to their "deadname" and consider any mention of it seriously offensive.) However, despite my downvotes (-4) I am unconvinced by that argument and the other replies. I don't think it's important to do this at all.
- eridius 7y agoYou've acknowledged that people transitioning is a huge motivation to change username, and yet say you aren't convinced. Why not? What's the benefit to not allowing usernames to change?
- logicallee 7y agoif allowing a change in username, do you think you should or shouldn't make visible a list of past usernames somewhere?
- bmm6o 7y agoStack Overflow
- evanweaver 7y agoThis was a big value point for Twitter in the early days (2008 and 2009 era). Identity is fluid.
- Jedd 7y agoYears ago I had a regrettable experience working for an alleged telco in London that perpetrated myriad sins against humans and technology alike. Their spin on this problem was that they'd decided very early on to use email address as the PK for their homespun all-things-to-all-people system. Shortly after they had to add an email column to address the predictable customer requests, and within a few years roughly half the user base was logging on with an email address they no longer used.
- zaphirplane 7y agoYears ago people used their ISP’s email service for email and when thru consolidation or choices their ISP changed they got a new email address. Now I find most people use an email provider and I don’t see a lot of ISP style emails
- FairKing 7y agoHave Virgin Media services (UK). They asked me to create as many email accounts as many services I signed in. I dont use those email addresses anywhere else, just to access they pages to pay bills. Who are those programmers, where are they from and how much they get paid. :-(
- FairKing 7y agoThe funniest thing is I could not use my original email as it is already used somewhere in the system and I have no clue when it happened. :-)
- Groxx 7y agonearly every assumption I usually see baked into a user model is eventually invalidated. and adding caching columns like "num of actions" are pretty common too, but that tends to mean your whole (fat) row is frequently invalidated, thrashing a bunch of caches. break apart your user tables! if you have constraints on pieces of info, put the constraints there, not on the user!
- dang 7y agoIt sounds like you are under the impression that we don't rename accounts. We do.
- eridius 7y agoI did figure that if I were to email hn@ and ask, you'd probably be able to rename my account, but this isn't exposed anywhere in the UI (or even the FAQ), and links to profiles are based on username rather than some internal ID.