10.4 should support functions as defaults but I cannot get it to work, I just get a string literal of the function name. This is a small personal project but should I use UNHEX and REPLACE("-","") to shrink down the UUIDs and save them as BINARY(16) instead of VARCHAR(36)? Is that the best practice?Ĭan I use UUID() as a default value with phpMyAdmin in MariaDB 10.4?Īt the moment I'm using triggers because that's what I'm used to, this is all being developed in XAMPP so I am using phpMyAdmin. Is that the way to go even if my UUIDs will be public?ĭo I need to store UUIDs as Binary(16) instead of VARCHAR(36)? Its already in place, and has no relation to any PDO code. While any internal function you dont have to 'pass' anywhere or bind it. So, as long as you have four placeholders in your SQL query, you have to bind exactly four variables to your PDO statement. I read another post that said you could use newer UUID functions BIN_TO_UUID and UUID_TO_BIN to be able to index UUIDs but it's more efficient. While placeholder have to be used only to represent the external data. Should I just use my UUID column as the P_Key even though they're public? Is that fine or is that crazy? It seems redundant to have 2 columns instead of 1 but I read you shouldn't expose your primary keys to the public and the INT column should be more efficient right? I used to use a "Created" column and index on that but I don't really need it and that seems worse than INT. Then the "id" column would be the actual UUIDs. So my first thought was to just have a vanilla, INT column that is Auto-Increment + Primary Key and called it "idx" for Index. I just have some general questions about how to go about this.Ĭan I just have an "index" column that is only there to act as a primary key? I'm creating some fake DBs to demo an API I'm working on in PHP so my data will have public UUIDs for each row. But I would feel more confident I think, if the IDs are not that "obvious" to read.I've been using MySQL for years but not necessarily efficiently. I am not saying it will happen - I use a token valid for 21 days (mobile application) and check if the issue date is older than 3 hours to refresh it (using a refresh token), which is then checked against the database to see if it's still the same - this refresh token is automatically changed when the password is changed for which the original password is needed. The reason why I would like to do this, is because if a JWT gets compromised and the secret to sign it is also compromised, the data could be corrupted and simply change the userID to, let's say, 122 and then that user would have access to all the data of userID 122 instead of 173. I read that this might slow down on inserts, but this would only happen when a new user signs up so I don't think it should be that big of an issue (it's not like a table filled with posts which have 100s of inserts on a daily basis). I am now wondering if I should change my userIDs to UUIDs. For example, my payload looks like this: userID: 173 The issue I am now facing is that I use a JSON Web Token to authenticate the user and store the userID in the payload. Currently, those have regular id's with a primary key - so my user IDs are 0, 1, 2, 3. In the database, I have a table "users" which contains the information about a user. I am building an application with a node.js backend in combination with MySQL.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |