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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:58:49+00:00 2026-05-25T16:58:49+00:00

this is the query from tutorial i read CREATE TABLE Employee ( id MEDIUMINT

  • 0

this is the query from tutorial i read

CREATE TABLE Employee (
id MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
departmentId TINYINT UNSIGNED NOT NULL
    COMMENT "CONSTRAINT FOREIGN KEY (departmentId) REFERENCES Department(id)",
firstName VARCHAR(20) NOT NULL,
lastName VARCHAR(40) NOT NULL,
email VARCHAR(60) NOT NULL,
ext SMALLINT UNSIGNED NULL,
hireDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
leaveDate DATETIME NULL,
INDEX name (lastName, firstName),
INDEX (departmentId)
)

what is the function of INDEX name (lastName, firstName) ?

Please inform me if my question is not clear.

Thank you,
GusDe

  • 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-25T16:58:50+00:00Added an answer on May 25, 2026 at 4:58 pm

    INDEX name (lastName, firstName) is creating an additional index for fast lookups when you are querying using the lastname with or without the first.

    It is a composite index because it includes two columns.

    Added The author of the tutorial is “guessing” that employees will often be looked up by their name or by their departmentID. That’s why he or she created the two additional indexes.

    — The primary key index is automatically created for you in most dbms systems.

    In real life, it is not wise to solely rely on “guessing” what columns in the tables should be indexed. Instead, use the “slow queries” log (MySQL example) to determine what queries are executing slowly and how to speed them up. Usually the answer is to add another index or two.

    ps. The downside of indexes is that they increase the time required to add, update or delete data in the table since the table and the index have to be modified. A second downside of indexes is that they take up room in the db. But storage is cheap these days.

    Since most databases have far more reads than writes, the speedup in querying provided by the index usually far outweighs the costs.

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

Sidebar

Related Questions

Take this query: SELECT * FROM MyTable WHERE MyColumn = 'SomeValue' ORDER BY SomeFakeQualifier.MyColumn
I have this query: SELECT * FROM sample INNER JOIN test ON sample.sample_number =
I got a problem with this linq query: from PersistedFileInfo fi in m_Database from
Let's say I have this query: select * from table1 r where r.x =
I have this query in LINQ to Entities. var query = (from s in
In a SQL Server 2005 database I'm working on this query: select * from
I have this SQL query: SELECT * FROM IMAGES WHERE IMAGENAME in ('IMG1', 'IMG2',
When using this SQL query: Select * from table_name what happens if the name
I need to get UserCarId(int) from this query and assign to int type variable.
I have a Linq query that looks something like this: var query = from

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.