Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3998836
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:34:39+00:00 2026-05-20T07:34:39+00:00

I have a table called members. I am looking on advice how to improve

  • 0

I have a table called members. I am looking on advice how to improve it.

  • id : This is user id (unique) (auto increment) (indexed)
  • status : Can contain ‘activated’, ‘suspended’, ‘verify’, ‘delete’
  • admin : This just contains either 0 or 1 (if person is admin or not)
  • suspended_note : If a members account is suspended i can add a note so when they try and login they will see the note.
  • failed_login_count : basically 1 digit from 0 to 4, counts failed logins
  • last_visited : unix timestamp of when they last visited site; (updated on logout) (i do this via php with time() )
  • username : can contain from 3 to 15 characters (unique and indexed)
  • first_name : can contain letters only and from 3 to 40 chars in length
  • last_name : can contain letters only and from 2 to 50 chars in length
  • email : can contain an email address (i use php email filter to check if valid)
  • password : can contain from 6 to 10 chars in length and is hashed and contains fixed length of 40 chars in database once hashed
  • date_time : unix timestamp (i do this via php with time() ). When user logs in
  • ip : members ip on registration/logins
  • activationkey : i use md5 and a salt to create a unique activation key; length is always 32 chars
  • gender : either blank or male/female and nothing else.
  • websiteurl: can add they site url;
  • msn : can contain msn email address (use regular expression to match this)
  • aim : aim nickname (use regular expression to match this)
  • yim : yim nickname (use regular expression to match this)
  • twitter : twitter username (use regular expression to match this)

suspended_note; first_name; last_name; date_time; ip; gender; websiteurl; msn; aim; yim; twitter can be null because on registration only username, email and password is required so those fields will be null until filled in (they are basically optional and not required) apart from ip which is taken on signup/login.

Could anyone tell me based on the information I have given how I can improve and alter this table more efficently? I would say I could improve it as I tend to use varchar for most things and am looking to get the best performance out of it.

I tend to do quite a few selects and store the user data in sessions to avoid having to query database every time. Username is unique and indexed like id as most of my selects compare have username in it with LIMIT 1 on my queries.

UPDATE:

I wanted to ask if I changed to enum for example how would I do a select and compare query for example in php for enum? I did look online but cannot find any example queries with enum being used. Also if I changed date_time for example to timestamp do I still use time() in php to insert the unix timestamp into date_time column database?

The reason I ask is I was reading one tutorial online that says when the row is queried, selected, updated etc MySQL automatically updates the timestamp for that row; is this true as I rather insert the timestamp using php time() in timestamp field. I use php time() already for date_time but use currently use varchar not timestamp.

Plus server time is in US and in php.ini I set it to UK time but I guess mysql would store it in the time on the server which again is no good as I want them in UK time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:34:39+00:00Added an answer on May 20, 2026 at 7:34 am

    Some tips:

    • Your status should be an int connected to a lookup, or an enum.
    • ditto for gender
    • You could use a char instead of varchar. There is a lot of discussion available on that, but while varchar does help you cut down on the size, that is hardly a big issue most of the time. char can be quicker. this is tricky point though.
    • safe your date_time as a timestamp. There is a datatype for that
    • ditto for last_visited
    • Your ip field looks a bit long to me.
    • an int(5) can hold too much. So if your failed count is max 4, you don’t need that big of a number! A tinyint can hold upt o 127 signed, or 255 unsigned.

    A note from the comments:

    You could probably normalize some
    fields: fields that update often, like
    failed_login_count, ip, last_visited
    could be in another table. This way
    your members table itself doesn’t
    change as often and can be in cache

    I agree with this 🙂

    Edit: some updates after your new questions.

    example how would I do a select and compare query for example in php for enum?

    You can just compare it to the value as if it was a string. The only difference is that with an insert or update, you can only use the give value. Just use

    SELECT * FROM table WHERE table.enum = "yourEnumOption"
    

    changed date_time for example to timestamp do I still use time() in php to insert the unix timestamp into date_time column database?

    You can use now() in mysql? (this is just a quick fromthetopofmyhead, could have a minor mistake, but:

    INSERT INTO table (yourTime) VALUES (NOW());
    

    reason I ask is I was reading one tutorial online that says when the row is queried, selected, updated etc MySQL automatically updates the timestamp for that row; is this true as I rather insert the timestamp using php time() in timestamp field. I use php time() already for date_time but use currently use varchar not timestamp.

    You can use the php time. The timestamp does not get updated automatically, see the manual (http://dev.mysql.com/doc/refman/5.0/en/timestamp.html): you would use something like this in the definition:

    CREATE TABLE t (
    ts1 TIMESTAMP DEFAULT 0,
    ts2 TIMESTAMP DEFAULT CURRENT_TIMESTAMP
                  ON UPDATE CURRENT_TIMESTAMP)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table called ApprovalTasks... Approvals has a status column I also have
Assume I have a table called User . Using LINQ desinger, I will end
I have a database table called ' members '. Assigned to members is a
I have a User entity which represents a User table in my database. This
In the database I have a table called SERVICE. For this table I have
Ok, let's suppose we have members table. There is a field called, let's say,
I have table called stats . In am inserting yes or no in the
i have table called as Support, which have a field named Name and contains
I have table called Buttons. Buttons table i have column button_number . Table contain
I have table called posts in my DB. Each post has field called social_network

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.