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.
970
questions
-1
votes
1
answer
18
views
how to implement crudRepository saveAll method on entity with primary composite key [closed]
I am trying to use repository.save(entityModel) and getting
"Inferred type 'S' for type parameter 'S' is not within its bound; should extend 'com.gta.model.TorKafkaLogModel'" exception
I am ...
-3
votes
0
answers
23
views
Composite Primary and Foreign Key in SQLITE? [closed]
SQLite code
In the Subscribers table I have both primary and foreign keys which are zsm related so are the same attributes. I get an error when creating this table. All other tables I created without ...
0
votes
0
answers
36
views
Should I use a id column in my MySQL table if the primary key can be derived from two other fields?
I am creating a MySQL table to store the concept of "a user follows another user". Of course, one user follows another or not, but more than one registry saying the same doesn't make any ...
0
votes
2
answers
31
views
Remove composite primary key for the join table created by entity framework
I have two classes, Product and Invoice, with many to many relationship between them
Entity framework has created three tables for me, Products, Invoices, and a join table called, InvoiceProducts (or ...
0
votes
1
answer
66
views
JPA / Hibernate, duplicate pkey error when updating entity that is a subclass of a base class that uses IdClass for composite primary key
How to reproduce this issue
https://github.com/cuipengfei/Spikes/tree/master/jpa/ClassIdUpdateIssue
this code can reproduce the issue, just run the main method then the error will happen.
https://...
0
votes
1
answer
47
views
How to improve a SQL Server table insertion performance by primary key or non-clustered index with uniqueness constraint? [closed]
In order to control the duplicate rows in a SQL Server table, which approach will have the better performance for insert times in high loads?
Create a primary key constraint on a column that should ...
-1
votes
2
answers
42
views
Composite keys and unique constrains performances and alternatives
I'm creating a database using MySQL for a music streaming application for my school project. It has a table "song_discoveries" which has these columns: user_id, song_id and discovery_date. ...
0
votes
0
answers
41
views
Spring JPA CriteriaQuery groupBy based on only one key in a Composite Primary Key (@EmbeddedId)
I am trying to write a criteriaQuery and group results based on emailId, which is one of the keys of a composite PK, embedded into one of my Entity classes.
The method that returns the specification ...
0
votes
1
answer
26
views
How to be sure there is no partition key override without using sort key on Dynamodb [duplicate]
In my code I am creating partition keys for user forms and sending metadata of them to dynamodb. I use lambdas for this and using some auto-increment function to be sure that counter is increased 1 ...
0
votes
1
answer
43
views
Oracle APEX Creating surrogate keys for composite PK
I have two tables I need to process.
One table "Delivery" contains id of delivery as PK, id of storage to deliver as FK and id of storekeeper as FK.
The other table "Delivery_log" ...
0
votes
1
answer
49
views
OLAP Data Warehouse - composite primary key as multiple or single fields
I'm building a data warehouse, and the data is of a quality where 8 fields may be required to uniquely identify a record, and this applies to three tables, each of which will have a few million rows ...
0
votes
0
answers
26
views
How can I do a ManyToOne Annotation in JPA with joinColum from a class who have a primaryKey pair association target error
Hello everyone i have this error when i launch my application :
An association that targets entity from entity 'has 1 '@JoinColumn's but the primary key has 2 columns.
My problem is to create a ...
0
votes
0
answers
91
views
Is it possible to use together @Id (from JPA) and @Generated (from Hibernate) annotations for a field which is part of a composite primary key?
We have an entity which is using a composite primary key (we are using @IdClass approach because we want to use our custom ID generator). This composite key is defined like this:
@NoArgsConstructor
@...
0
votes
1
answer
39
views
Replacing two columns (first name, last name) with an auto-increment id
I have a time-series location data table containing the following columns (time, first_name, last_name, loc_lat, loc_long) with the first three columns as the primary key. The table has more than 1M ...
0
votes
1
answer
25
views
Key-Range equivalent in Redis? Coming from DynamoDB
In DynamoDB I use a composite key to model the one-to-many relationship in a table:
User (Key) - Order (Range)
A typical set of records there is like:
John - Burger
John - Fries
Sue - Pizza
Sue - Soda
...
0
votes
1
answer
55
views
How best to update row where composite primary key values change
We have numerous tables where we have composite keys with MULTIPLE entries. In some cases as many as SIX values that make up the primary key for a table that is not super large, maybe a few thousand ...
1
vote
1
answer
179
views
Composite Primary key, using @IdClass - Column 'id' cannot be null
I have an entity with a composite primary key.
id - version will be the primary key.
id
version
column A
1
1
some data
1
2
some data
2
1
some data
2
2
some data
I am using @IdClass for handling ...
0
votes
0
answers
24
views
How to index the automatic primary key or create a primary key in another way in VB.NET
I created a winform desktop application vb.net with a DBF database and a DBF database in use in a dos application. So is there a solution to re-index the winform without having to re-load the form or ...
0
votes
0
answers
25
views
Laravel Sanctum protecting a model with a composite primary key
I want my Laravel 8 application to handle tokens for IOT devices interfacing an API.
My original model had a composite primary key like this, and note the composite primary key.
<?php
namespace ...
1
vote
1
answer
106
views
JPA Hibernate Problem for One to One Relationship with Embedded ID
I am struggling with the following problem that I've been trying to solve. After checking solutions on StackOverflow and articles on Baeldung I still get different JPA errors when trying to map the ...
1
vote
1
answer
30
views
How to map JPA OneToMany relationship when FK is part of CompositeId
So I have a pre-existing Service Entity with multiple OneToMany relationships. Now I need to add one more but I am having trouble and I assume it must be because the Many side uses a Composite Key.
I ...
0
votes
0
answers
71
views
Composite Key with Date Key
I have a Dimension which uses a composite Primary key to identify a single row (3 keys), and one of those keys happens to be the Date from the Source Table. This Date from the Source i do a Left Join ...
0
votes
1
answer
52
views
Composite Primary Key and autoincremented ID
I am trying to build a composite primary key for my tabels. They should also have a self incremented id. My problem is that when I use a composite primary key the ID becomes NULL (as seen in the ...
0
votes
1
answer
82
views
Google Spanner - Java Mutation - Delete rows with subset of composite key values
I have a requirement where I need to delete rows based on the subset of composite keys via mutation.
I have a table
CREATE TABLE FOO
(KEY1 INT64, KEY2 INT64, KEY3 INT64, VALUE STRING(100))
PRIMARY KEY ...
0
votes
0
answers
89
views
How do I make both these columns as a composite primary key?
I have a model in sequelize that stores like dislike votes. It needs to know which post was liked/disliked and by which user. I am using sequelize-typescript
likeDislike.model.ts
/* eslint import/no-...
0
votes
1
answer
38
views
MappingException: broken column mapping during mapping one to one with joinTable
I explain the Global context. I want to create a simple system composed of two entities, an agency and employee. I want to model the notion of agency manager. Indeed, an agency with one and only one ...
0
votes
1
answer
60
views
django admin site returns MultipleObjectsReturned exception with inspectdb imported legacy database and composite primary key
Using inspectdb, I have imported a legacy database, that contains entities with composite primary keys, in django . The database schema contains about 200 different entities and inspectdb is quite ...
0
votes
0
answers
91
views
Trying to create a Composite Primary Key in MSSQL with only a part of 2 columns
I'm new to SQL and am following a course, however it does not cover the "create table" part.
It only covers statements etc.
What I would like to have is, my primary key (cust_id) to be ...
0
votes
0
answers
38
views
Why doesn't EF core code first like my composite key?
public class UserDocuments
{
[Key]
[StringLength(30)]
public string UserID { get; set; } = string.Empty;
[Key]
public Guid DocumentID { get; set; } = Guid.Empty;
public ...
-1
votes
1
answer
59
views
Creating a foreign key against a composite key in MS SQL Server
I'm trying to create a foreign key between two tables. Problem is one of those tables has a composite primary key..
My tables are products (one row per product) and product_price_history (many rows ...
-1
votes
1
answer
53
views
Auto incrementing composite key
I have a relatively simple need -- I have a table with a composite primary key that includes an integer index to be autoincremented. However, I cannot figure out how to do this.
I have read the ...
-1
votes
2
answers
59
views
Is there a way to generate composite key efficiently in a PostgreSQL database?
Suppose I have a student table with id as primary key, which holds information about all students.
id | name
---+------
1 | aaron
2 | bob
In addition there is a table where id and tid form a ...
2
votes
1
answer
45
views
Could not view with composite pK CakePHP4
In cakephp-4.x I could not access Controller's view action for composite primary key table. (http://localhost:8765/invoice-items/view/1)
Here are samples of the code created by cake bake:
...
-1
votes
1
answer
65
views
Postgres FK referencing composite PK INSERT VIOLATION
I am trying to insert into a table (mdata) which has a compost foreign key referencing to a primary keys in another table (measurement), unfortunately I have this error
ERROR: insert or update on ...
0
votes
0
answers
29
views
EF6 with BaseEntity and composite key
I would like to know your opinions and advices about BaseEntity and composite key.
I found a lot example how we use BaseEntity class in EF but I am confused because all example project and explanation ...
0
votes
0
answers
103
views
Laravel Eloquent model architecture and pivot table with composite keys
I have a Laravel specific problem, maybe caused by creating database model without previous Eloquent knowledge, and now I am really struggling with correctly retrieving required data.
Situation:
There ...
0
votes
0
answers
237
views
Kotlin Android Room Composite primary key many to many relation
I have got two tables: equipment and location. Equipment table has composite primary key consisted of columns "component_id", "id". Location table has primary key "id".
...
0
votes
1
answer
486
views
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity:
I have 2 tables with One to Many Relationship and one table has composite primary key.
Table 1: Key_Numbers – Columns - ID_UNIK( Primary Key) and other columns
Table2: Key_Number_xml – Columns - ...
-1
votes
3
answers
815
views
where clause with composite primary key
For example I have a composite primary key on columns id, age in the following table:
id
age
name
1
23
John
2
24
Alex
3
22
Rob
4
20
Ella
can I somehow query the table using composite primary key ...
0
votes
0
answers
209
views
Postgresql - Optimize ordering of columns in table range partitioning with multiple columns range
I am testing with creating a data warehouse for a relatively big dataset. Based on ~10% sample of the data I decided to partition some tables that are expected to exceed memory which currently 16GB
...
0
votes
2
answers
956
views
How to use a composite primary key with Entity Framework from a foreign key in C#
I’ve got a large problem with an existing database and the primary key / foreign keys using Entity Framework.
It's an existing database and it is not allowed to change the database, at least not the ...
2
votes
1
answer
336
views
How can I have my composite primar key in a junction table using sequelize?
I have a composite primary key in my table Foo, and a single primary key in Bar. When I make a junction using the belongsToMany syntax, only one primary key component shows up in the junction table (...
0
votes
0
answers
83
views
JPA Composite Key: Avoid Unnecessary of Table Creation
I am learning JPA.
I need to create 3 tables, product (pk => id), cart (pk => id), cart_details (pk also fk => product_id, cart_id).
The relation is : One cart can contain multiple ...
0
votes
1
answer
116
views
Unique clustered index vs primary key
I have a table with composite primary key of 7 fields, but table is allowing duplicate entries with primary key. Later I noticed it also has Unique clustered index with 10 fields including 7 of ...
4
votes
1
answer
1k
views
Does indexing on a part of a composite primary key is needed in Postgresql?
I have a (large) table with a composite primary key, composed of 5 columns (a, b, c, d, e).
I'd like to efficiently select all rows having two of those columns (a + e) to a given value.
In PostgreSQL, ...
1
vote
1
answer
215
views
cascading update on subset from composite foreign-keys
i have the below posted tables.As shown, the table GridCell has all the rows as composite primay-key, and they are foreign-keys in table GridCellOpDependentParticular. the same applies on the table ...
3
votes
1
answer
428
views
Knex multiple primary key in a identify relationship where id is an auto increment column
I tried to use every single logic in my mind to resolve this problem, but this is the only solution that it worked.
knex.schema.createTable('documents', (table) => {
table.integer('id')....
0
votes
1
answer
32
views
How to create a table such that when ever a record is inserted, composite key values gets inserted in another column?
I could find many methods to create a unique composite key while creating a table. But I was unable to figure out how i can create a column that contains composite key values automatically whenever a ...
-1
votes
1
answer
36
views
Mysql - Table design for authorization checking
I have a table called Student and it is used to save the relationship between Class and Student
Class
Student (PK)
Class 1
Peter
Class 1
Harry
Class 2
Sally
Class 2
Tommy
And there is another ...
0
votes
1
answer
120
views
Expressing identifying and non-identifying relationships in MySQL
Context
I'm learning about identifying and non-identifying relationships, and I'm wondering how I'd express them in MySQL. For practice, I've been working on a database for Pokemon. For context, every ...