compound-key

Compound keys in JPA

拥有回忆 提交于 2019-12-12 07:55:45
问题 I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA? I want to do this because the primary key should be used as foreign key in another table and making it compound would not be good. In the following snippet, I need the command and model to be unique. pk is of course the primary key. @Entity @Table(name = "dm_action_plan") public class ActionPlan { @Id private int pk; @Column(name = "command",

ssas compound dimension key

僤鯓⒐⒋嵵緔 提交于 2019-12-12 05:36:53
问题 I'm using SSAS Visual Studio 2010. I have a dimension with a compound key pointing to a fact table. To begin with, the compound key contained three keys, and now I need to add a fourth. I did this in the DSV by clicking between the arrow between them and selecting the new fields from the dropdown menus. So far so good. I saved the DSV and reprocessed my cubes. Here's where the problem starts: I noticed only very minor changes in the relevant reports... I expected either wholesale changes or

How to set cascade on SQLite database with compound primary foreign key?

荒凉一梦 提交于 2019-12-11 10:16:35
问题 I have a db that's structured with a supertype table as well as subtype tables like so: EVENT PatientId INTEGER, DateTime TEXT, EventTypeCode TEXT, PRIMARY KEY( PatientId, DateTime, EventTypeCode ) different types of events have their own tables and have the same primary key, except that it's foreign. EXERCISE PatientId INTEGER, DateTime TEXT, EventTypeCode TEXT, PRIMARY KEY( PatientId, DateTime, EventTypeCode ) ON CONFLICT IGNORE, CONSTRAINT "PrimaryKey" FOREIGN KEY ("PatientId",

Map with multiple keys in C++

一世执手 提交于 2019-12-10 14:51:43
问题 I want to store data by both, their name and their index. In other words, I want to map string names to objects and also give them a custom order. What I came up with first is a std::vector of pairs of the string key and the object. The order was given by the position in the vector. std::vector<std::pair<std::string, object> > But this approach seems to be suboptimal since it doesn't automatically check for the uniqueness of string names. Moreover it feels wrong to group the objects by their

Compound key in Realm with lazy property

廉价感情. 提交于 2019-12-07 13:02:51
问题 I found this great solution for using Realm with compound primary key in Swift: https://github.com/realm/realm-cocoa/issues/1192 public final class Card: Object { public dynamic var id = 0 { didSet { compoundKey = compoundKeyValue() } } public dynamic var type = "" { didSet { compoundKey = compoundKeyValue() } } public dynamic lazy var compoundKey: String = self.compoundKeyValue() public override static func primaryKey() -> String? { return "compoundKey" } private func compoundKeyValue() ->

Compound/Composite primary/unique key with Django

爱⌒轻易说出口 提交于 2019-12-06 18:45:02
问题 How can you create models (and thus tables) with a compound (composite) primary/unique key using Django? 回答1: Django does not support compound primary keys. You can create a single compound unique key with Meta.unique_together. 回答2: if you want only unique mixed fields together use belowcode: class MyTable(models.Model): class Meta: unique_together = (('key1', 'key2'),) key1 = models.IntegerField() key2 = models.IntegerField() But if you want unique together and one of column be primary, set

Compound key in Realm with lazy property

社会主义新天地 提交于 2019-12-06 04:07:08
I found this great solution for using Realm with compound primary key in Swift: https://github.com/realm/realm-cocoa/issues/1192 public final class Card: Object { public dynamic var id = 0 { didSet { compoundKey = compoundKeyValue() } } public dynamic var type = "" { didSet { compoundKey = compoundKeyValue() } } public dynamic lazy var compoundKey: String = self.compoundKeyValue() public override static func primaryKey() -> String? { return "compoundKey" } private func compoundKeyValue() -> String { return "\(id)-\(type)" } } But I discovered that Realm does not support lazy properties, in my

Compound/Composite primary/unique key with Django

笑着哭i 提交于 2019-12-04 22:40:11
How can you create models (and thus tables) with a compound (composite) primary/unique key using Django? Django does not support compound primary keys. You can create a single compound unique key with Meta.unique_together . if you want only unique mixed fields together use belowcode: class MyTable(models.Model): class Meta: unique_together = (('key1', 'key2'),) key1 = models.IntegerField() key2 = models.IntegerField() But if you want unique together and one of column be primary, set primary argument for model column, similar below code: class MyTable(models.Model): class Meta: unique_together

Compound keys in JPA

不问归期 提交于 2019-12-03 12:55:39
I want to make an entity that has an autogenerated primary key, but also a unique compound key made up of two other fields. How do I do this in JPA? I want to do this because the primary key should be used as foreign key in another table and making it compound would not be good. In the following snippet, I need the command and model to be unique. pk is of course the primary key. @Entity @Table(name = "dm_action_plan") public class ActionPlan { @Id private int pk; @Column(name = "command", nullable = false) private String command; @Column(name = "model", nullable = false) String model; } Michel

Reinstantiating EF classes with one-to-many relationship and compound key of strings

强颜欢笑 提交于 2019-12-02 08:23:52
I have the following EF Code First classes, which appear to be working to a point. I also have Initialization code that seeds these tables with data from elsewhere that is lengthy, and seems (I hope) inconsequential to my question. Or at the least when I seed manually I see the same behavior problem. Note, that these tables use strings as their primary keys, and not ID's. Also note that the SubCategory table has a compound primary key that includes the parent table, Category's primary key, CategoryCode. This is, perhaps, old school, ISAMish, but it is what I have to work with, and is otherwise