Jump to content

MySQL Data Types - have I used the right ones?


Recommended Posts

Hi all -

Just starting out with some code re-write on a project of mine, and was wondering if I have picked the right data types for my MySQL tables. Here is part of the onResourceStart stuff - it updates the accounts table.

  
mysql_query(databaseNode, "CREATE TABLE IF NOT EXISTS accounts (ID INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY)") 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD username varchar(32) NOT NULL") 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD password varchar(32) NOT NULL"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD registerDate datetime NOT NULL DEFAULT 0"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD lastLoginDate datetime NOT NULL DEFAULT 0"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD accountCash BIGINT UNSIGNED NOT NULL DEFAULT 1000"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD accountBankCash BIGINT UNSIGNED NOT NULL DEFAULT 1000"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnX SMALLINT NOT NULL DEFAULT 2019.142"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnY SMALLINT NOT NULL DEFAULT 1545.708"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnZ SMALLINT NOT NULL DEFAULT 10.827"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnInt SMALLINT NOT NULL DEFAULT 0"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnDim SMALLINT NOT NULL DEFAULT 0"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD spawnRot SMALLINT NOT NULL DEFAULT 270"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD playerSkin TINYINT UNSIGNED NOT NULL DEFAULT 0"); 
    mysql_query(databaseNode, "ALTER TABLE accounts ADD accountSerial VARCHAR NOT NULL DEFAULT 0"); 
  

Also note:

-Usernames are limited to 32 characters.

-Passwords are stored as MD5 hashes.

Thanks for the advice!

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...