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

  • Home
  • SEARCH
  • 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 399267
In Process

The Archive Base Latest Questions

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

Assume that we have two tables: Roles and Reports . And there exists a

  • 0

Assume that we have two tables: Roles and Reports. And there exists
a many-to-many relationship between them. Of course, the only solution
that comes to my mind is to create a cross-table, let’s name it RoleReport.
I can see two approaches to the structure of that table:

1. Columns: RoleReportId, RoleId, ReportId
   PK: RoleReportId
2. Columns: RoleId, ReportId
   PK: RoleId, ReportId

Is there any real difference between them (performance or whatever else)?

  • 1 1 Answer
  • 2 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-12T16:49:47+00:00Added an answer on May 12, 2026 at 4:49 pm

    You will need a composite UNIQUE index on (RoleId, ReportId) anyway.

    There is no point in not doing it a PRIMARY KEY.

    If you do it a CLUSTERED PRIMARY KEY (which is default), this will be better performance-wise, since it will be less in size.

    A clustered primary key will contain only two columns in each record: RoleID and ReportID, while a secondary index will contain three columns: RoleID, ReportID and RoleReportID (as a row pointer).

    You may want to create an additional index on ReportID which may be used to search all Roles for a given Report.

    There would be some point in making a surrogate key for this relationship if the two following conditions held:

    1. You have additional attributes in your relationship (i. e. this table contains additional columns, like Date or anything else)
      • You have lots of tables that refer to this relationship with a FOREIGN KEY

    In this case it would be nicer to have a single-column PRIMARY KEY to refer to in FOREIGN KEY relationships.

    Since you don’t seem to have this need, just make a composite PRIMARY KEY.

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

Sidebar

Related Questions

Assume that I have two parent tables: Company and Contact . Assume that both
I have two tables say ( FCT_SALES_SUMMARY_A and FCT_SALES_SUMMARY_B ). If we assume that
Let's say I have two tables with a one-to-many relationship. I want to create
I have two tables and I need to establish a 1-many relation among them,
Let's assume that I have two tables... Foo and Bar. They contain the following
To illustrate, assume that I have two tables as follows: VehicleID Name 1 Chuck
I have the following tables in my database that have a many-to-many relationship, which
I have two tables: boughtItems(buyerId,ItemId) and denormalized(buyerId,item1,item2,item3,item4,item5) Let's assume that in boughtItems table each
I have a city table that has two columns from_city to_city now lets assume
Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size).

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.