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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:13:30+00:00 2026-06-17T23:13:30+00:00

I have a table representing soccer matches: Date Opponent I feel {Date,Opponent} is the

  • 0

I have a table representing soccer matches:

  • Date
  • Opponent

I feel {Date,Opponent} is the primary key because in this table there can never be more than one opponent per date. The problem is that when I create foreign key constraints in other tables, I have to include both Date and Opponent columns in the other tables:

Soccer game statistics table:

  • Date
  • Opponent
  • Event (Goal scored, yellow card etc)

Ideally I would like to have:

Soccer matches table:

  • ID
  • Date
  • Opponent

Soccer match statistics table:

  • SoccerMatchID
  • Event (Goal scored, yellow card etc)

where SoccerMatch.ID is a unique ID (but not the primary key) and {Date,Opponent} is still the primary key.

The problem is SQL Server doesn’t seem to let me define ID as being a unique identity whilst {Date,Component} is the primary key. When I go to the properties for ID, the part signalling unique identifying is grayed-out with “No”.

(I assume everyone agrees I should try to achieve the above as it’s a better design?)

  • 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-17T23:13:31+00:00Added an answer on June 17, 2026 at 11:13 pm

    I think most people don’t use the graphical designer to do this, as it’s the graphical designer that’s preventing it, not SQL Server. Try running DDL in a query window:

    ALTER TABLE dbo.YourTable ADD ID INT IDENTITY(1,1);
    GO
    CREATE UNIQUE INDEX yt_id ON dbo.YourTable(ID);
    GO
    

    Now you can reference this column in other tables no problem:

    CREATE TABLE dbo.SomeOtherTable
    (
      MatchID INT FOREIGN KEY REFERENCES dbo.YourTable(ID)
    );
    

    That said, I find the column name ID completely useless. If it’s a MatchID, why not call it MatchID everywhere it appears in the schema? Yes it’s redundant in the PK table but IMHO consistency throughout the model is more important.

    For that matter, why is your table called SoccerMatch? Do you have other kinds of matches? I would think it would be Matches with a unique ID = MatchID. That way if you later have different types of matches you don’t have to create a new table for each sport – just add a type column of some sort. If you only ever have soccer, then SoccerMatch is kind of redundant, no?

    Also I would suggest that the key and unique index be the other way around. If you’re not planning to use the multi-column key for external reference then it is more intuitive, at least to me, to make the PK the thing you do reference in other tables. So I would say:

    CREATE TABLE dbo.Matches
    (
      MatchID INT IDENTITY(1,1),
      EventDate DATE, -- Date is also a terrible name and it's reserved
      Opponent <? data type ?> / FK reference?
    );
    
    ALTER TABLE dbo.Matches ADD CONSTRAINT PK_Matches
      PRIMARY KEY (MatchID);
    
    ALTER TABLE dbo.Matches ADD CONSTRAINT UQ_Date_Opponent
      UNIQUE (EventDate, Opponent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this table which has seven columns, each column representing a specific value
Suppose I have a table which has a CDATE representing the date when I
Pretend I have this table, hypothetically representing users (the voters) rating various objects (e.g.
I have a sqlite table representing a weighted directed graph. The columns are as
I have a table containing an url and a string representing its parameters. The
I have the following table of TIME datatypes clarification: I am representing hours/mins/seconds of
I have a simple temp-table defined in SQL Server 2008 R2 representing a parent-child
I have table with around 70 000 rows. There is 6000 rows that i
I have table and this table contain result column with some entries. I just
I have table with 300 000 records (MyISAM). I get record from this table

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.