Questions tagged [composite-primary-key]

Composite primary key is a primary key, which consists of more than one column. The column combination guarantees the uniqueness of the PK.

A Composite Primary Key is a Composite Key, which is assigned as Primary.

Primary key is a single field or the least combination of fields that uniquely identifies each record in table. When the primary key consists of more than one field, when we are talking about composite primary key. Composite or not, is the most appropriate key to be main key of reference for the table.

The primary key must not be null and must contain only unique values.

Primary keys are mandatory for every table. When choosing a primary key from the pool of candidate keys, always choose a single simple key over a composite key.

Links

984 questions
0
votes
1 answer

Strategy for implementing a composite key of which the second part is rarely discriminating. Entity Framework Code First

I have the following scenario: An Atom Entity is usually unique and can be stored in the database using a single AtomID field as its primary key.. In rare cases theAtomneeds to be split. In that case a second record must be created in the database…
0
votes
2 answers

how to alter table Composite primary key

CREATE TABLE [dbo].[INVS_ITEM_LOCATIONS] ([DEPARTMENT_CODE] [varchar](3) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [IM_INV_NO] [numeric](10, 0) NOT NULL, [LOCATION_CODE] [varchar](2) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL, [CURR_QTY]…
Domnic
  • 3,817
  • 9
  • 40
  • 60
0
votes
1 answer

Many to Many and Composite Primary Key and Foreign Key

I am building a system where there are properties and prospects, I have a table for both, but as I see this as a many to many relationship, I have created a table called prospect_property with two columns prospect_id and property_id, these are…
0
votes
1 answer

Composite primary key query

I have a composite primary key. The keys are in turn two entities. I want to query based on the entities inside the primary key. My intention is to query on the primary key something like this Criteria projCriteria =…
DebD
  • 374
  • 1
  • 4
  • 18
0
votes
0 answers

hibernate composite-id as a part other composite-id

I try to write mapping to tables. I decided that id and versionId - composite-id for table test. But in table test_question I have composite-id consists from question_id, test_id and versionId. I can't understand as I can use one composite-id…
Ray
  • 1,788
  • 7
  • 55
  • 92
0
votes
1 answer

MySQL/InnoDB: more optimal to have two non-unique index columns or combine them in unique primary key?

I'm using MySQL with InnoDB. I don't need a primary key in terms of semantics, so does a primary key (or rather, a unique index) make for faster queries than a non-unique index? I have two columns that are suitable for indexes but are non-unique.…
Display Name
  • 2,323
  • 1
  • 26
  • 45
0
votes
1 answer

Hibernate one-to-one with composite keys

I have an issue with my mapping file, relating to a one-to-one relationship, with composite primary keys, where the field names of the keys do not match. Table 1:
Memran
  • 405
  • 4
  • 12
0
votes
1 answer

Table name as part of primary key

I have an audit trailing system in my project from http://doddleaudit.codeplex.com/. As you can see on this image it records the EntityTable - which is the table name, and the EntityTableKey - which is the primary key I would like to associate the…
jekcom
  • 2,065
  • 2
  • 24
  • 34
0
votes
1 answer

Multiple SQL statements In Yii

I am trying to execute multiple sql statements in yii , this is to reduce round trips to the server . This is for a field called niche specialization . A maximum of three enteries are allowed for a user , however the field is optional . This is the…
Varun Jain
  • 1,901
  • 7
  • 33
  • 66
0
votes
1 answer

Yii has_many relationship with two primary_keys

I have a mail_conversation and a mail_conversation_member table. mail_conversation has only id as the PRIMARY KEY. mail_conversation_member has conversation_id and user_id as PRIMARY KEYs. Now, I want to list a conversation and all its members, but…
Garry Cat
  • 31
  • 1
  • 8
0
votes
1 answer

How to map these tables on Hibernate

I have these two tables: CREATE TABLE IF NOT EXISTS `functions` ( `idFunction` int(11) NOT NULL, `idLanguage` int(11) NOT NULL, `name` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `idCategory` int(11) DEFAULT '1', PRIMARY KEY…
0
votes
1 answer

Routing default CRUD interface for composite keys in Play Framwork

I am trying to create a successful route for an entity that only has a composite key so that i may navigate to the default CRUD module's 'edit' interface. Right now, I am successfully retrieving and displaying the list of all the club_admin's in the…
Luke
  • 776
  • 9
  • 24
0
votes
3 answers

A new column as primary key or use two FK as PK

I have the following database design: And I'm wondering if EReportReq must have a column as a primary key, eReportReqId, or maybe I can use eReportId and requirementId as primary key. Requirement table will have system information and EReport table…
VansFannel
  • 45,055
  • 107
  • 359
  • 626
0
votes
1 answer

Hibernate mapping many-to-many with composite key

I have these tables (with these primary keys): Resources - idResource (PK) - idResLanguage (PK) Tags - idTag (PK) Resources_Tags - idResource (PK) - idTag(PK) Is there any way to map these tables only referencing the field "idResource" in the…
frikkio
  • 93
  • 2
  • 10
0
votes
1 answer

MongoDB range query on manually created _id

I have a use case where storing an _id that is a composite of the following would be immensely useful: 96 bit int 96 bit int 96 bit int ObjectID This works out as a 36 byte ASCII string. It will be byte reversed to become big endian. I would like…
IamIC
  • 17,747
  • 20
  • 91
  • 154