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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:56:40+00:00 2026-05-16T07:56:40+00:00

Observe the following table model: CREATE TABLE [site].[Permissions] ( [ID] INT REFERENCES [site].[Accounts]( [ID]

  • 0

Observe the following table model:

CREATE TABLE [site].[Permissions] (
    [ID]     INT REFERENCES [site].[Accounts]( [ID] ) NOT NULL,
    [Type]   SMALLINT NOT NULL, 
    [Value]  INT NULL
);

The site.Accounts->site.Permissions is a one-to-many relationship so ‘ID’ cannot be made a primary key due to the uniqueness that a PK imposes.

The rows are selected using a WHERE [ID] = ? clause, so adding a phoney IDENTITY column and making it the PK yields no benefit at the cost of additional disk space.

Its my understanding that the targeted platform – SQL Server (2008) – does not support composite PKs. These all add up to my question: If a Primary Key is not used, so something wrong? Or could something be more right?

  • 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-16T07:56:40+00:00Added an answer on May 16, 2026 at 7:56 am

    Your understanding is not correct, SQL Server does support composite primary keys!

    The syntax to add one would be

    ALTER TABLE  [site].[Permissions] 
    ADD CONSTRAINT PK_Permissions PRIMARY KEY CLUSTERED (id,[Type])
    

    Regarding the question in the comments “What is the benefit of placing a PK on the entire table?”

    I’m not sure from your description though what the PK would need to be on. Is it all 3 columns or just 2 of them? If it’s on id,[Type] then presumably you wouldn’t want the possibility that the same id,[Type] combo could appear multiple times with conflicting values.

    If it is on all 3 columns then to turn the question around why wouldn’t you want a primary key?

    If you are going to have a clustered index on your table you could just make that the primary key. If say you made a clustered index on the id column only SQL Server would add in uniqueifiers anyway to make it unique and your columns are so narrow (int,smallint,int) this just seems a pointless addition.

    Additionally the query optimiser can use unique constraints to improve its query plans (though might not apply if the only queries on that table really are WHERE [ID] = ?) and it would be pretty wasteful to allow duplicates that you then have to both store and filter out with DISTINCT.

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

Sidebar

Related Questions

Let's say I have following table: CREATE TABLE `occurences` ( `object_id` int(10) NOT NULL,
I have a following table: CREATE TABLE IF NOT EXISTS `Tree` ( `id` int(10)
Please observe the following markup: <Style TargetType={x:Type MenuItem} x:Key=...> <Setter Property=HeaderTemplate> <Setter.Value> <DataTemplate> <ContentPresenter
QUESTION How can I create a MySQL table so, that a field's default value
Observe the following trivial anonymous type in C# new { X = 5 };
Observe the following .NET type: public class X { public DateTime Timestamp {get;set;} public
In my view file I type the following: <table> <tr> <td><%= link_to(tag(:div, {:class =>
How do I translate the following to instead use PrototypeJS Event.observe? <input type=text ....
Observe the following code: private List<List<Place>> m_grid = constructGrid(10000); private static List<List<Place>> constructGrid(int size)
Observe the following code trait Example { type O def apply(o: O) def f(o:

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.