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

  • Home
  • SEARCH
  • 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 4335546
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T10:41:04+00:00 2026-05-21T10:41:04+00:00

I am trying to design a user table for MySQL. for now, my user

  • 0

I am trying to design a user table for MySQL.

for now, my user table looks like this

users (
BIGINT id,
VARCHAR(?) username,
VARCHAR(?) password,
VARCHAR(254) email,
DATETIME last_login,
DATETIME data_created
)

what other fields should I also include and why do I need them?

what fields should I exclude from above and why?

how many characters should I allocate for username and password, and why?

should I use BIGINT for id?

Thank you in advance for your helps.

ADDED
I am going to use the table for social web site, so ‘users’ mean people around the world.

  • 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-21T10:41:05+00:00Added an answer on May 21, 2026 at 10:41 am

    A few comments:

    1. BIGINT is fine. I assume you’re using it as a surrogate key. In that case, declare it as

      BIGINT id primary key auto_increment,

      Mysql will automatically allocate a unique int value to your id whenever you do an insert (don’t specify any value for this field). Never try to implement this behaviour by selecting the max id and adding 1 to it (I’ve seen this so many times).

    2. Length of username and password: this is no big deal really, just pick a length. I tend to standardise on 255 length varchars for these things but that’s not based on anything empirical.

    3. Call your table “user”, not “users”. Conceptually, a table implements an entity in the same way that a class implements an entity. You will likely create a class or data structure called “user” and the table name should correspond to this.

    4. Every table that I create has two timestamps, “created” and “last_updated”. You’re halfway there:)

    5. I don’t think I would store last_login in the user table, this is likely to be something that you will want to log in a separate table. It’s a good idea to store all login events (login, logout, failed attempt, account lock etc.) in a logging table. This will give you much better visibility of what the system has been doing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to determine the best table design for a follow/unfollow user feature, similar
I'm trying to design a MySQL database to store user zipcode preferences for providing
I'm trying to design a simple user table with a primary key userid ,
I am just trying to design skype like message window , for this I
Basically i've a table for my users (it's nightclub website) and now i'm trying
I am trying to design an IDE-like (Non-Editable) program with a richtextbox control. Basically,
I am trying to design my Class Diagram. But I get stuck on this
I am trying to design some kind of user to user relationship, such as
I am trying to design an efficient database schema for user settings in SQL
I am trying to design a location lookup in which the user can specify

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.