Questions tagged [compound-key]

Questions regarding usage of compound key (specific composite key) in database

76 questions
3
votes
4 answers

Get aggregate sum of data by day and hour

The below is an example of the data I have. date time size filename day.of.week 1 2015-01-16 5:36:12 1577 01162015053400.xml Friday 2 2015-01-16 5:38:09 2900 01162015053600.xml Friday 3 2015-01-16 5:40:09…
James White
  • 535
  • 10
  • 24
3
votes
1 answer

JPA compound key with foreign key and enum

Hi all, Im trying to build all the jpa entities out of a legacy database. I have a recurrent problem: some "main" entities have a collection of "translations", where the primary key is the key of the "main" + the "language" identifier. Languages are…
landoooo
  • 153
  • 2
  • 10
2
votes
2 answers

array_key_exists for compound key in array

How do I check to see if a compound key exists with array_key_exists such as $myarr['ind1']['ind2'] Would like to see if the key ['ind1']['ind2'] exists in $myarr. I googled this and looked at some similar answers but couldn't find anything.
macmiller
  • 325
  • 1
  • 4
  • 15
2
votes
1 answer

How does MySQL handle compound unique indexes with limited lengths?

Assuming two columns in a MySQL (MyISAM) table: title VARCHAR(1500) url VARCHAR(155) I want to create a composite unique index on both columns. I know of the limiting length feature for too long columns (like my title column). How does it play with…
Aufwind
  • 25,310
  • 38
  • 109
  • 154
2
votes
0 answers

mongodb compound keys duplicate key error

I'm facing a duplicate key error without finding a solution. I have a compound key created using the following command: db.test.createIndex({"a":1,"b":1,"date":1},{unique:true}) then I inserted a document: { "a": "test_a", "b":…
2
votes
2 answers

JPA Compound key with @EmbeddedId

In a legacy database, I have three tables: Users, Workgroups, and UsersWorkgroup. UsersWorkgroup stores what role a user has in a workgroup. Here are the relevant code snippets: @Entity @Table(name = "users_workgroup") public class UsersWorkgroup…
egbokul
  • 3,944
  • 7
  • 36
  • 54
2
votes
1 answer

Why use a compound clustered key in Cassandra tables?

Why might one want to use a clustered index in a cassandra table? For example; in a table like this: CREATE TABLE blah ( key text, a text, b timestamp, c double, PRIMARY KEY ((key), a, b, c) ) The clustered part is the a, b, c part of the…
user1529891
2
votes
1 answer

Cassandra cluster key usage

I'm banging my head on this, but, frankly speaking, my brains won't get it - or so it seems. I have a column family that holds jobs for a rather large group of actors. It is a central job management and scheduling table that must be distributed and…
2
votes
1 answer

Breeze.js: error when assigning compound foreign key with GUID and integer values

I'm encountering an error with Breeze.js version 1.4.12. I have an entity, OrderLine, that has a compound primary key consisting of one GUID field (OrderId) and one integer field (LineNumber). This entity has a self-referencing foreign key,…
aifdsc
  • 21
  • 1
2
votes
1 answer

CQL3 change primary key

Suppose I have a table of the following composition. CREATE TABLE rollup ( hashname text, key text, day timestamp, counter_value counter, PRIMARY KEY (hashname, key, day) ) WITH ... I want to run a query that looks like SELECT * FROM…
Peter Klipfel
  • 4,958
  • 5
  • 29
  • 44
2
votes
1 answer

creating a compound or composite key on google app engine

I have two models: Car(ndb.Model) and Branch(ndb.Model) each with a key method. @classmethod def car_key(cls, company_name, car_registration_id): if not (company_name.isalnum() and car_registration_id.isalnum()): raise…
2
votes
1 answer

SQL compound Key

I am trying to create a table that as a Primary Key uses Values from other tables.My lectures said that this is a compound key (Primary+Foreign) yet I can't seem to be able to find how to initiate one.Can someone try to explain this concept and how…
2
votes
3 answers

Is it possible to (emulate?) AUTOINCREMENT on a compound-PK in Sqlite?

According to the SQLite docs, the only way to get an auto-increment column is on the primary key. I need a compound primary key, but I also need auto-incrementing. Is there a way to achieve both of these in SQLite? Relevant portion of my table as I…
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
1
vote
0 answers

Advanced JPA Mapping with Compound keys - OneToMany relationship

I am using JPA 1.0 and have following tables, namely, Type, Guide and Address (names simplified for clarity and highlighted in bold) It is a scenario, where in relationships between 3 tables is built on compound keys. Non key fields for every table…
user721025
  • 172
  • 5
  • 15
1
vote
1 answer

How can I create a model with compound foreign key?

anybody knows on how to create a model with compound foreign key to another model. e.g. UserInfo: userId, password, key, ... GeoInfo: id, userId, password, storeName, ... In the above sample models. Want to link GeoInfo to UserInfo using two fields…
eros
  • 4,946
  • 18
  • 53
  • 78