foreign-keys

Hibernate Composite Key: foreign key has wrong number of columns

谁说胖子不能爱 提交于 2019-12-11 04:06:54
问题 I am new to Hibernate and JPA and am having difficulty setting up a composite key as defined below: @Entity @Table(name = Entity.TABLE) @IdClass(EntityPK.class) public class MyEntity extends Entity { @CollectionOfElements @JoinTable(name="items", joinColumns = @JoinColumn(name="items")) private List<String> items; @Id private Type type; @Id private Level level; // plus standard constructors/getters/setters } public class EntityPK implements Serializable { private Type type; private Level

Entity Framework 4 Databinding on WinForms ComboBoxes with Foreign Keys

谁说胖子不能爱 提交于 2019-12-11 04:02:20
问题 I am using Entity Framework 4, I need to get WinForms to bind Customers and Quotes as a Master - Detail relationship. I have a Quote table which I lay out as details view on a Windows Form. The quote table has 3 foreign keys to the customer table. (fields CustomerId, SiteCustomerId, InvoiceCustomerId which all link to Id field in the Customer table). On the form there are 3 Customer panels with the Customer Name fields in a ComboBox, and other Customer detail fields in textBoxes. How do I

Order of deletion with foreign key constraints,

落爺英雄遲暮 提交于 2019-12-11 03:54:28
问题 I have a schema with three tables and foreign key 'On Delete' constraints as below: | -> FK (cascade) -> | Organisation | | Users | - FK (cascade) Categories -> FK(restrict) -> | If I delete an organisation I want to delete the users and the categories related to it, but I can't allow a category to be deleted if a user refers to it except in the case where the whole organisation is being deleted. At present if I delete an organisation the category deletion fails if there's a user referring to

Linq to Sql Foreign key relationships

白昼怎懂夜的黑 提交于 2019-12-11 03:46:30
问题 Table name: Author AuthorID -> primary key FirstName LastName Table name: Titles ISBN -> primary key BookTitle EditionNumber CopyRight Table name: AuthorISBN ISBN -> foreign key AuthorID -> foreign key How come the below code block below does not trigger the intellisense, since Linq-to-SQL automatically creates properties based on foreign-key relationship? In my case it doesn't... ERROR: The name title does not exist in current context in title.AuthorISBN It's not letting me add a photo, but

Cannot add Foreign Key on tables in DashDB / DB2 on Bluemix

与世无争的帅哥 提交于 2019-12-11 03:34:07
问题 When I create a table in DashDB (DB2) on Bluemix like this: CREATE TABLE DEPARTMENT ( depname CHAR (10) UNIQUE NOT NULL , phone INTEGER ) ; ALTER TABLE DEPARTMENT ADD CONSTRAINT DEPARTMENT_PK PRIMARY KEY ( depname ) ; CREATE TABLE EMPLOYEE ( "EmpNr" NUMERIC (3) UNIQUE NOT NULL , empname CHAR (20) , depname CHAR (10) , EMPLOYEE2_title CHAR (20) ); ALTER TABLE EMPLOYEE ADD CONSTRAINT EMPLOYEE_PK PRIMARY KEY ( "EmpNr" ) ; ALTER TABLE EMPLOYEE ADD CONSTRAINT EMPLOYEE_DEPARTMENT_FK FOREIGN KEY

Why does this T-SQL OUTPUT INTO with FOREIGN KEY hack work?

扶醉桌前 提交于 2019-12-11 03:13:40
问题 The base example is lifted from No way to use TSQL Output with normal foreign key constraints?; his code fails as expected. But if the way the constraint is defined in the example is modified as below, defining the FK constraint WITH NOCHECK and then CHECK ing it, the OUTPUT INTO will run unimpeded. This seems to contradict the OUTPUT clause docs. Specifically: output_table [the table receiving the INTO] cannot: •Have enabled triggers defined on it. • Participate on either side of a FOREIGN

Why cannot use 2 separate foreign keys for same model in django model

橙三吉。 提交于 2019-12-11 03:07:51
问题 I have a theoretical model that isn't working: class Message(models.Model): text = models.TextField() created = models.DateTimeField(auto_now_add=True) sender = models.ForeignKey(User) receiver = models.ForeignKey(User) Now if a user messaged someone, like a private message thread, you have someone who sent it, and someone who received it, which is important to know. Both of these should be a one-to-many I think because each user can send infinite messages. Senders and receivers are users,

Foreign keys, where they belong depending on relationships

北战南征 提交于 2019-12-11 03:05:58
问题 I've worked with databases a fair bit ( MySQL, Oracle ) though typically only DML as the systems had been previously engineered. I'm working on a project as the sole developer, and am responsible for application development, and DBA; the latter of course proving more problematic. In any case - I need a refresh on foreign key constraints, and their logical placement in a model. Given the following: dbc_user .user_id INT, Primary Key, Auto Increment // arbitrary columns dbc_user_profile .user

Magento - Unable to reindex Product Prices - Foreign Key Constraint Fails

北慕城南 提交于 2019-12-11 03:03:14
问题 I've just recently upgraded my magento store from 1.4.2 to 1.7.0.2.. And The upgrade went smoothly but when I try to reindex data after the upgrade.. It fails on the Product Prices.. I've tried using php shell/indexer.php --reindexall from SSH and it fails at the Product Prices with these errors (I use pastebin as the error are quite long): http://pastebin.com/iV2tuzDX From what I can see, the table catalog_product_index_tier_price is empty.. and I'm not sure if that is causing any issue? I

How create composite foreign key to table with composite primary key

对着背影说爱祢 提交于 2019-12-11 01:48:30
问题 I have two tables with composite primary keys: public class Event { [Key] [Column(Order = 1)] public string ID1 { get; set; } [Key] [Column(Order = 2)] public int ID2 { get; set; } public DateTime EventDate { get; set; } public string DocID1 { get; set; } public int DocID2 { get; set; } } public class EventDocument { [Key] [Column(Order = 1)] public string ID1 { get; set; } [Key] [Column(Order = 2)] public int ID2 { get; set; } public string Name { get; set; } public string SurName { get; set