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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:20:12+00:00 2026-06-05T05:20:12+00:00

I know this is very basic and given where I’m at with Databases I

  • 0

I know this is very basic and given where I’m at with Databases I should probably understand this by now, but I do not fully comprehend what an index really is.

To make it concrete, the following is the T-SQL generated by an ORM – it creates an FK and then creates an index for it.

What does having the index do (in the posative sense) and what does excluding it do (in the negative sense)?

-- Creating foreign key on [item_id] in table 'CakeStats'
ALTER TABLE [dbo].[CakeStats]
ADD CONSTRAINT [FK_CakeStat_Item]
    FOREIGN KEY ([item_id])
    REFERENCES [dbo].[Items]
        ([id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;

-- Creating non-clustered index for FOREIGN KEY 'FK_CakeStat_Item'
CREATE INDEX [IX_FK_CakeStat_Item]
ON [dbo].[CakeStats]
    ([item_id]);
GO
  • 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-05T05:20:14+00:00Added an answer on June 5, 2026 at 5:20 am

    An index is a balanced tree that allows faster searching for specific data. Indexing something in a general sense is marking it for easy finding. Visualize an index in the back of a reference book. It’s alphabetically sorted to allow for quick finding of where the actual information is at the cost of extra pages in the back of the book making it larger/thicker. The more stuff you index, the larger that is. There is also a difference between a clustered and nonclustered index. The example I gave above is a nonclustered index so it’s in addition to the normal book contents. A clustered index is the actual content itself sorted by the keys of the index.

    In the foreign key case, if you foreign key something, the way the key is enforced is by doing a check on the referenced table/column to see if it exists. Having an index on the foreign key greatly speeds up the look up (log(n) time) rather than require looking at every single row one at a time (n time).

    In your example, the index only helps if a query searches CakeStats based on item_id. It actually is very important that Items(id) also has an index or the check on foreign key is going to be expensive every time item_id is inserted/deleted/updated in CakeStats.

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

Sidebar

Related Questions

I know, this might be a very basic question but I am not 100%
guys I know this question is very basic but I've met in few publications
Ok, I know this is a very basic question, but my head is swimming
I know this seems to be a very basic questions but I can't figure
I know this is very basic but i am frustrated like anything.. i googled
This is a very very basic question and I know one way is to
I know this is very evil, but is it possible to add an object
I know this is very similar to a few other questions, but I can't
I know this is a very broadly scoped question, but what do I need
Sorry, I know this is a very lame question to ask and not of

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.