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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:36:45+00:00 2026-05-13T22:36:45+00:00

Just like stackoverflow, there is a many-to-many relationship between Question and Tag. After running

  • 0

Just like stackoverflow, there is a many-to-many relationship between Question and Tag.

After running these symfony commands:

./symfony doctrine:drop-db
./symfony doctrine:build-db
./symfony doctrine:build-model
./symfony doctrine:build-sql
./symfony doctrine:insert-sql

With the following schema:

schema.yml

Tag:
 columns:
   name:
     type: string(10)
     notnull: true
 relations:
     Questions:
       class: Question
       foreignAlias: Tags
       refClass: QuestionTag

Question:
  columns:
    html:
     type: string(1000)
  relations:
     Tags:
       class: Tag
       foreignAlias: Questions
       refClass: QuestionTag

QuestionTag:
  columns:
    question_id:
     type: integer     
     primary: true
    tag_id:
      type: integer      
      primary: true
  relations:
    Question:
      class: Question
      foreignAlias: QuestionTags
      type: many
      foreignType: one
    Tag:
      class: Tag
      foreignAlias: QuestionTags
      type: many
      foreignType: one

In the QuestionTag linking table, which helps establish the many-to-many relationship between Tag and Question tables, I found that Doctrine only created a ‘normal’ index on the tag_id column. Why on this column but not on the question_id column? I don’t know.

I think this is strange, because the index that Doctrine creates should be on both question_id and tag_id columns, and so it should become a ‘unique’ index, rather than a ‘normal’ one, because question_id and tag_id together form the composite primary key.

Is my understanding correct?
If yes, why doesn’t Doctrine do it in the correct way?

  • 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-13T22:36:45+00:00Added an answer on May 13, 2026 at 10:36 pm

    I believe Doctrine doesn’t support composite primary (or foreign) keys. Remember, the Doctrine project is moving along extremely quickly but it’s still fairly young. New features are being added all the time, though I don’t think multi-column keys are planned for the 1.x branch.

    The workaround would be to create a unique primary key column, question_tag_id, as one of the 3 fields in the QuestionTag table.

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

Sidebar

Related Questions

There have been many times on StackOverflow where a user asks a question like
Just like in JavaScript : opener.document.getElementByName jQuery: ?? Is there any way to get
Sorry for the unlearned nature of this question. If there's a simple answer, just
I simplified a many-to-many relationship case with these mockup tables. Posts: ------------------------------ | id
Many times just find the right article and reading it on StackOverflow helped me
We have all seen many question on StackOverflow that are founded upon the idea
I'm trying to implement a tab menu just like the one in Stack Overflow.
Just like in the title. I got GridView control that displaying some data from
Just like I said, my winform application works properly on computers with VS installed,
Just like what happens when you click Sign in with OpenID on http://twitterfeed.com/ ,

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.