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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:42:59+00:00 2026-05-20T07:42:59+00:00

I am having a problem with creating my database in SQL Server Compact I

  • 0

I am having a problem with creating my database in SQL Server Compact

I basically have 5 tables ( CentreDeCout, Profil, Groupe, CCProfilPivot, CCProfilGroupePivot)

CentreDeCout has NomCC as primary key

Profil has NomProfil as primary key

CCProfilPivot has NomCC and NomProfil as primary key ( referenced to CentreDeCout and Profil primary key)

Groupe has NomGroupe as primary key

and I need CCProfilGroupePivot to have the primary key of CCprofilPivot and NomGroupe as its primary key.

So the primary key would be NomCC, NomProfil and NomGroupe.

NomCC and NomProfil would be taken from CCProfilPivot and
NomGroupe from Groupe

This is how I did it

  
CREATE TABLE CentreDeCout(
NomCC nvarchar(100) primary key
)

CREATE TABLE Profil(
NomProfil nvarchar(100) primary key
)

CREATE TABLE Groupe(
NomGroupe nvarchar(100) primary key
)

CREATE TABLE CCProfilPivot(
NomCC nvarchar(100) references CentreDeCout(NomCC),
NomProfil nvarchar(100) references Profil(NomProfil),
PRIMARY KEY(NomCC,NomProfil)
)


CREATE TABLE CCProfilGroupePivot(
NomCC nvarchar(100) references CCProfilPivot(NomCC),
NomProfil nvarchar(100) references CCProfilPivot(NomProfil),
NomGroupe nvarchar(100) references Groupe(NomGroupe),
PRIMARY KEY (NomCC,NomProfil,NomGroupe)
)

The last create table gives me this error


SQL Exercution Error.

Exercuted SQL statement: CREATE TABLE CCProfilGroupePivot( NomCC nvarchar(100) references CCProfilPivot(NomCC), NomProfil nvarchar(100) references CCProfilPivot(NomProfil), NomGroupe nvarchar(100) references Groupe(NomGroupe), PRIMARY KEY (NomCC,NomProfil,NomGroupe) )

error Source: SQL Server Compact ADO.Net Data Provider Error Message: The referenced table must have a primary or candidate key.[FK Name = FK_CCProfilGroupePivot__00000000000000D7]

Can anyone please help me?

Thank you
Gibit

  • 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-20T07:42:59+00:00Added an answer on May 20, 2026 at 7:42 am

    You have to reference both columns of a compound key at the same time.

    CREATE TABLE CCProfilGroupePivot(
      NomCC nvarchar(100) not null,
      NomProfil nvarchar(100) not null,
      NomGroupe nvarchar(100) references Groupe(NomGroupe),
      PRIMARY KEY (NomCC,NomProfil,NomGroupe),
      foreign key (NomCC, NomProfil) 
        references CCProfilPivot (NomCC, NomProfil)
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having problems with SQL Server dropping a connection after I have dropped
Having real problems creating a DB on my version of SQL Server 2008 R2
We were having a problem with our build server not checking out modifications from
I'm having a weird issue concerning Microsoft SQL Compact Edition. In a Windows.Forms application,
Iam having problem creating postgresql function in plperl CREATE OR REPLACE FUNCTION zm_json (TEXT,
I'm having a problem creating a C# P/invoke wrapper around a third party C
I am having a problem creating a directory with specific permissions. //Make sure Tools
I am new to OOP having this code and am having a problem creating
I'm having the following problem. I have Visual Web Developer 2010 Express and I'm
I have one question that if we are creating any table in database i.e.

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.