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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:41:38+00:00 2026-05-28T00:41:38+00:00

I am new to SQL and I have a basic question about performance. I

  • 0

I am new to SQL and I have a basic question about performance.

I want to create a users database which will store information about my users:

  • Id
  • Log in name
  • Password
  • Real name

Later I want to perform a SELECT query on: Id, Log in name and Real name.

What would be the best design for this database, what tables and what keys should I create?

  • 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-28T00:41:39+00:00Added an answer on May 28, 2026 at 12:41 am

    If it’s only about those 4 fields it looks like just one table. Primary key on ID, unique index on LoginName. You may not want to store the password, but only a hash.

    Depending on your queries, create different indexes. Furthermore, you may not need the ID field at all.

    UPDATE:
    Creating an index on certain column(s) enables the database to optimize its SQL statements. Given your user table:

    USER
        USER_ID BIGINT NOT NULL
        LOGIN_ID VARCHAR(<size>) NOT NULL
        PASSWORD VARCHAR(<size>) NOT NULL
        NAME VARCHAR(<size>) NOT NULL
    
    CONSTRAINT PK_USER PRIMARY KEY ( USER_ID )
    

    The databases I know will automatically create an index on the primary key, which in fact means that the database maintains an optimized lookup table, see WikiPedia for further details.

    Now say, you want to query users by LOGIN_ID which is a fairly common use case, I guess, you can create another index like:

    CREATE INDEX I_USER_1 ON USER ( LOGIN_ID asc )
    

    The above index will optimize the select * from USER where LOGIN_ID='foo'. Furthermore, you can create a unique index instead, assuming that you do not want duplicate LOGIN_IDs:

    CREATE UNIQUE INDEX UI_USER_1 ON USER ( LOGIN_ID asc )
    

    That’s the whole story, so if you want to optimize a query for the users real name (NAME), you just create another index:

    CREATE INDEX I_USER_2 ON USER ( NAME asc )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new to performance engineering, so I have a very basic question. I'm
I have a very basic question about SQL server and Visual Studio 2010. I'm
Hi I'm very new to sql but have been passed a job in which
I'm pretty new to SQL. I have a database with records based on road/milepoints.
I'm brand new to SQL Server 2008, and have some newbie questions about the
I have another SQL/access 2007 question that seems really basic but I'm not sure
im very new to this and have a very basic knowledge php and SQL
I'm not a DBA, but I have some basic understanding about how SQL Server
I'm a bit new to SQL and have trouble constructing a select statement. I
I have SQL server 2000 dev edition. But it isn't compatible with my new

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.