referential-integrity

(doctrine2 + symfony2) cascading remove : integrity constraint violation 1451

眉间皱痕 提交于 2019-12-28 05:45:06
问题 First, sorry for my poor English... I got four entities : User, Application, Bundle & Entity. Here are their relations (with cascading persist & remove, see code below) : User 1-n Application Application 1-n Bundle Bundle 1-n Entity It's working fine. But an User can have two of his entities as default, and I need to access them directly. So I add on User two fields, entity1 & entity2, with a 1-1 relation. And now my app crashes : An exception occurred while executing 'DELETE FROM bundle

There is a way to enforce referential integrity in MongoDB [duplicate]

守給你的承諾、 提交于 2019-12-24 22:16:14
问题 This question already has answers here : How to enforce foreign keys in NoSql databases (MongoDB)? (6 answers) Closed 7 months ago . When you search for referential integrity in relation to Mongo-DB the standard response is "MongoDB does not support this". The standard explanation is that MongoDB supports refs and populate, however there is nothing that prevents you changing the ref to an invalid value. This is a major deterrent for many developers coming from a SQL background. 回答1: THERE IS

Syncing referential integrity tables and enums

走远了吗. 提交于 2019-12-23 09:57:56
问题 I ponder this question from time to time, so I thought I'd ask you guys about it. Let's say I have a database table that looks like this: Table: Visibility Id Value -- ----- 0 Visible 1 Invisible 2 Collapsed This is just a table for ensuring referential integrity. It is basically an enum stored in the database for the purposes of ensuring that any Visiblity values that appear in other tables are always valid. Over in my front end, I have some choices. I could query this table and store it in,

How to reference groups of records in relational databases?

一个人想着一个人 提交于 2019-12-22 09:25:40
问题 Suppose we have the following table structures: Humans | HumanID | FirstName | LastName | Gender | |---------+-----------+----------+--------| | 1 | Issac | Newton | M | | 2 | Marie | Curie | F | | 3 | Tim | Duncan | M | Animals | AmimalID | Species | NickName | |----------+---------+----------| | 4 | Tiger | Ronnie | | 5 | Dog | Snoopy | | 6 | Dog | Bear | | 7 | Cat | Sleepy | I wonder how to reference a group of records in other tables. For example, I have a Foods table and an EatenBy

“polymorphism” for FOREIGN KEY constraints

妖精的绣舞 提交于 2019-12-22 03:48:09
问题 There is this field in a table: room_id INT NOT NULL CONSTRAINT room_id_ref_room REFERENCES room I have three 2 tables for two kinds of rooms: standard_room and family_room How to do something like this: room_id INT NOT NULL CONSTRAINT room_id_ref_room REFERENCES standard_room or family_room I mean, room_id should reference either standard_room or family_room . Is it possible to do so? 回答1: Here is the pattern I've been using. CREATE TABLE room ( room_id serial primary key, room_type VARCHAR

How to enforce referential integrity on Single Table Inheritance?

半腔热情 提交于 2019-12-22 02:34:33
问题 I've read some of Bill Karwin's answers about single table inheritance and think this approach would be good for the setup I am considering: Playlist -------- id AUTO_INCREMENT title TeamPlaylist ------------ id REFERENCES Playlist.id teamId REFERENCES Team.id UserPlaylist ------------ id REFERENCES Playlist.id userId REFERENCES User.id PlaylistVideo ------------- id playlistId REFERENCES Playlist.id videoId REFERENCES Video.id All the CASCADE options are set to DELETE which will work

mysql circular dependency in foreign key constraints

血红的双手。 提交于 2019-12-18 04:38:16
问题 Given the schema: What I need is having every user_identities.belongs_to reference an users.id . At the same time, every users has a primary_identity as shown in the picture. However when I try to add this reference with ON DELETE NO ACTION ON UPDATE NO ACTION , MySQL says #1452 - Cannot add or update a child row: a foreign key constraint fails ( yap . #sql-a3b_1bf , CONSTRAINT #sql-a3b_1bf_ibfk_1 FOREIGN KEY ( belongs_to ) REFERENCES users ( id ) ON DELETE NO ACTION ON UPDATE NO ACTION) I

How to deal with mutually recursive inserts

此生再无相见时 提交于 2019-12-18 03:42:00
问题 I have a model that defines mutually recursive tables: Answer questionId QuestionId text Question text correct AnswerId What do I need to do to actually insert a question? I need to know what the correct answer is first. But to insert an answer, I need to know what question it answers. I'm running Postgres, if it matters. The DDL is: CREATE TABLE answer ( id integer NOT NULL, -- answer id text character varying NOT NULL, -- answer text question_id bigint NOT NULL -- question id ); CREATE

SQL Server foreign key to multiple tables

倾然丶 夕夏残阳落幕 提交于 2019-12-17 20:47:51
问题 I have the following database schema: members_company1(id, name, ...); members_company2(id, name, ...); profiles(memberid, membertypeid, ...); membertypes(id, name, ...) [ { id : 1, name : 'company1', ... }, { id : 2, name : 'company2', ... } ]; So each profile belongs to a certain member either from company1 or company2 depending on membertypeid value members_company1 ————————— members_company2 ———————————————— ———————————————— id ——————————> memberid <——————————— id name membertypeid name /

Integrity constraint violation in Magento custom module

纵饮孤独 提交于 2019-12-17 18:46:08
问题 I have a similar probelm to Integrity constraint violation creating Product in Magento (unanswered) but I am creating a custom Observer that hooks into the catalog_product_save_after event - based on this tutorial: http://fishpig.co.uk/blog/custom-tabs-magento-product-admin.html However whenever a new product is saved I get this error: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '22-1' for key 'UNQ_CATALOGINVENTORY_STOCK_ITEM_PRODUCT_ID_STOCK_ID' The config.xml looks