There are ISO country codes.
https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
There are ISO country codes.
https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
This and nothing else. Had to deal with way too many APIs that would use some sort of homebrew schema.
Am I supposed to make an SQL statement that puts these country codes into a table, along with the country's name? There's probably a better way. Maybe I could make a new entry for every unique country a user is from
Why do you need to store the name of a country in the database? Frontend can take the country code and display a full name on its own, and do it in a localized way too.
not sure I understand the distinction between the "am I supposed to" and "maybe I could" parts?
You should create a table of all countries, you can just copy that from the above link. Then you reference that table with a foreign key in your users table.
Sooooo I copy paste every single country code and put it in a table?
If you can't figure out how to get a foreign table into your database let someone who knows databases do it for you
How exactly you create that table is up to you of course, I don't know enough about your project setup.
Store a jpg of the country's flag as binary
You're supposed to use PNG for images of that sort, you fucking barbarian.
I'll use a gif with each frame being a different country flag. Then I can access them by frame index.
Better use FHD png to keep the quality.
That's what you got emoji for.
Well shit, that's weirdly viable.
It really is.
This should be the standard :)
This is the only real way to do it, the other solutions involve "standards" which more often than not aren't all encompassing. Make sure that any user input of a country is just them uploading the jpg of their home country without any sort of validationbecausee everyone is loyal to their home country.
An important question no-one has asked yet is, What do you need that info for?
I store iso country codes and use them as the primary key in a countries table.
Same for using an "almost non-changing" standard, i.e. either ISO or RFC. And write a script to update the data or tables if something wrong changes (like Russia disappearing because it has been invaded by Belgium), you never know what might happen politically.
I'd store it as a string (ISO code), pretty much every programming language has icu data for country names.
If you need more data later, it's very simple to migrate.
GPS coordinates. Much more efficient than storing country, province, city, address, and postal code. Let the front end handle the rest.
Terrible idea for a few reasons.
I guess you meant that as a joke, but people are really doing this and it leads to actual problems.
I saw a news report a while ago about something like that being done in a database for people with outstanding debt. If the address of the debtor wasn't known, they just put "US" in the form, and the program automatically entered the centre of the US as the coordinates.
Sucks for the family that lives there because they constantly get threatening mail and even house visits from angry lenders who want their money back. People even vandalized their house and car because they believed that their debtors lived in that house.
Yep, meant it as a joke.
In that case, woosh me. Just wanted to make sure nobody takes that as an actual advice.
GPS? Absolutely insufficient. What about the people on the ISS? Or when the moon base is established? Ever thought of that? No. You think only of yourself.
Simple, add additional columns for the frame of reference (e.g. Earth) and elevation. You could even store space coordinates using Sun as a reference point (though you would need to update data regularly for spacecraft as they move of course).
Fine, we'll add altitude as well.
You should also include the standardized name of the body the coordinates are relative to. Need to be able to differentiate between lat/long on Jupiter vs on Earth (where lat/long are much more "crunched" aka more precise with shorter floats).
This will be important if intelligent extraterrestrial life is found, or when Musk ships himself to Mars for the good of humanity.
Out of scope for the project, we'll flush it from the backlog and include it in another epic.
What about alternative universes? 🤣
They have their own databases, no additional info required.
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Follow the wormhole through a path of communities !webdev@programming.dev