473,471 Members | 2,138 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to choose the composite primary key for a table

1 New Member
Hellow, I am new to MS SQL Server and I have been designing a database for my company. I am using Microsoft Visio for desigin and in my database design, I am planning to use composite primary key for a table with the sole reason of avoiding to have a seperate dedicated unique id as a primary key. When I have to use this composite primary key as a Foreign Key in another table, when building the relationship, in the referring table all the coulmns that makes up the composite primary key are getting into the table. Where in fact, I need only one colums as a foreign key on that table and the rest of the columns is just memory overhead. I am not getting how to get around this problem. I am really new to MS SQL and please try to provide me a good solution by benig as informative as possible.
Oct 27 '10 #1
1 3078
gpl
152 New Member
If only one of the columns of your composite primary key is needed to uniquely identify the row (which is what you are saying) then that surely is the primary key ? Any other columns are not needed. If this is not the case, then your foreign key on the oher table could refer to more than 1 row on the master
Oct 27 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: onder | last post by:
i have a master table with around 15 columns and i am trying to find the appropriate primary keys and indexes for the table. To make the records unique, i need to include two datetime columns (...
2
by: Shaun Evans | last post by:
Is is possible to create a composite primary key on a table variable? Neither of these two statements are successful: DECLARE @opmcjf TABLE ( jobdetailid INT NOT NULL, cjfid INT NOT NULL,...
5
by: John | last post by:
Specifically for joint tables... tblStudents tblClasses tblClasses_Students Is it be good programming to use a composite primary key in tblClasses_Students (where the key is ClassID and...
18
by: Thomas A. Anderson | last post by:
I am a bit confused in creating a composite primary key. I have three table with two of the tables containing primary keys. I have two of the tables (each with a primary key) having one to many...
6
by: mac | last post by:
Summary: 1. I want to define a column in anMS Access table to be lookups on other tables. 2. The table that is the data source (e.g the "parent" table) has a composite primary key. 3. When...
3
by: bvdrsganesh1981 | last post by:
Hi Can We Create a Foreign Key Relation in Table1 with a Table2 Table 2 having Composite Primary key with columns T2Col1,T2Col2,T2Col3, T2Col4 where first 3 columns are composite primary...
3
by: TheIntern | last post by:
I have two fields in a table,first name and last name.Both the fields contain duplicate values.Say, there are two people with the firstname mary.their last names are andrews and mathews.SQL Server...
7
by: Ronald S. Cook | last post by:
My client manager likes concatenated/composite primary keys. I don't. Can anyone forward any arguments pro or con? Thanks, Ron
1
by: mallz | last post by:
hi, i have two tables: table1: mid,name table2: mid,did,location now, i need to increment against a particular mid value.... how can that be done? please help.
4
by: Wolfgang Keller | last post by:
Hello, so far it seems to me as if the only ORM module for Python which supports composite primary/foreign keys was SQLAlchemy. Which looks a little bit "overbloated" for my needs: I "just" need...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.