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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:19:00+00:00 2026-05-26T23:19:00+00:00

create table foo (id, name) create table bar (id, foo_id, value, …) We created

  • 0
create table foo (id, name)
create table bar (id, foo_id, value, ...)

We created a foreign key relationship for foo_id referencing foo(id), which seems to be creating an index for the same column implicitly. We also have a requirement to create a compound index based on foo_id, value in bar.

Does it make sense to declare the indexes in the above mentioned fashion or is there a way to optimize index creation in the above case?

  • 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-26T23:19:00+00:00Added an answer on May 26, 2026 at 11:19 pm

    It depends on how you use it. The indexes are to speedup the queries’ executions and foreign keys are to make the content of your database consistent.

    When it comes to foreign keys, here is a part of Foreign Key constraints documentation:

    InnoDB requires indexes on foreign keys and referenced keys so that foreign key checks can be fast and not require a table scan.

    So everything is ok with the indexes created when the foreign keys are created.

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

Sidebar

Related Questions

create table foo (id, name) create table bar (id, name) create table foo_bars (foo_id,
create table foo (id, name varchar(255)); create table foo_values (id, foo_id, name varchar(255), value
create table foo (id, name, order, ...); create table foo_bar (id, foo_id, name, value);
create table foo (id, name varchar(255), value varchar(255)); Does it make sense to index
If I issue the following commands: CREATE TABLE foo LIKE bar; INSERT INTO bar
I have table with a name filed which is string. I need to create
In C# Given a hash table like {id:'1', name:'foo'} How can I dynamically create
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT
Consider a simple table with an auto-increment column like this: CREATE TABLE foo (
For the sake of the example, consider a table create table foo ( contents

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.