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 8905855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:30:03+00:00 2026-06-15T02:30:03+00:00

I am implementing a very simple user database for a website I am creating,

  • 0

I am implementing a very simple user database for a website I am creating, and naturally I want to make sure I am working as close to “best practices” as possible. The database is in MySQL and I am struggling with the table definition.

CREATE TABLE IF NOT EXISTS 'users' (
  `user_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'auto incrementing user_id of each user, unique index',
  `user_email` varchar(254) COLLATE utf8_unicode_ci COMMENT 'user''s email',
  `user_password_hash` text COLLATE utf8_unicode_ci NOT NULL COMMENT 'user''s password in salted and hashed format',
  PRIMARY KEY (`user_id`),
  UNIQUE KEY `user_email` (`user_email`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='user data' AUTO_INCREMENT=1 ;

I borrowed this table definition from php-login.net, and edited it to make user_email the unique key (the original had it as a text field, non unique).

After doing some reading, I have seen a few comments that say having a unique key/index that is this large(254*3 bytes) implies a bad database design and the fact the MySQL has a max key length of 1000 bytes makes me think I am doing something wrong. Can this database be improved or is it fine the way it is?

I do not know the inner workings of indexing in MySQL and the amount of overhead involved so I assume it is more than possible that a key this large is just not efficient.

Thanks for the help.

  • 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-06-15T02:30:04+00:00Added an answer on June 15, 2026 at 2:30 am

    Making the email a unique index is fine to act as a constraint and improve lookups by email, but why not decrease the size of the email field? How many 254 character email addresses do you plan to have and can you sacrifice them by making the column a varchar(128)? I wouldn’t use it for your primary key, keep your auto incrementing bigint.

    As far as other best practices, why append user_ to every column in the user table? Is there any column in the user table that does not apply to a user record? Just use id, email etc… When writing queries user.id and user.email is cleaner than user.user_id and user.user_email. Also, when you use the as foreign keys in other tables, you just refer to them as user_id, from that I can tell the foreign key is the id column of the user table. Do this consistently throughout your database.

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

Sidebar

Related Questions

I am implementing a very simple file database. I have 2 basic operations: void
I am having trouble implementing image rotation in CUDA. I have a very simple
I'm implementing a very simple conversation system on mongodb. The idea should be that
I am implementing a simple recommendation system for a collection of user created components.
I'm implementing a very simple FTP server program that is able to retrieve and
I'm implementing a very simple audio-only RTMP server. I have my client code like
We are currently working on a very simple Webapp, and we would like to
http://pstreams.sourceforge.net/ pstreams is an apparently very simple library, re-implementing popen() for C++. The library
I'm having a problem with implementing a very simple HashTable using an array. The
I'm currently implementing a very complex tree structure to allow for near-instant data access,

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.