Foreign key constraint may cause cycles or multiple cascade paths?

SQL Server does simple counting of cascade paths and, rather than trying to work out whether any cycles actually exist, it assumes the worst and refuses to create the referential actions (CASCADE): you can and should still create the constraints without the referential actions. If you can’t alter your design (or doing so would compromise … Read more

How to add “on delete cascade” constraints?

I’m pretty sure you can’t simply add on delete cascade to an existing foreign key constraint. You have to drop the constraint first, then add the correct version. In standard SQL, I believe the easiest way to do this is to start a transaction, drop the foreign key, add a foreign key with on delete … Read more

“Insert if not exists” statement in SQLite

If you never want to have duplicates, you should declare this as a table constraint: CREATE TABLE bookmarks( users_id INTEGER, lessoninfo_id INTEGER, UNIQUE(users_id, lessoninfo_id) ); (A primary key over both columns would have the same effect.) It is then possible to tell the database that you want to silently ignore records that would violate such … Read more

Turn off constraints temporarily (MS SQL)

— Disable the constraints on a table called tableName: ALTER TABLE tableName NOCHECK CONSTRAINT ALL — Re-enable the constraints on a table called tableName: ALTER TABLE tableName WITH CHECK CHECK CONSTRAINT ALL ——————————————————— — Disable constraints for all tables in the database: EXEC sp_msforeachtable ‘ALTER TABLE ? NOCHECK CONSTRAINT ALL’ — Re-enable constraints for all … Read more

Add primary key to existing table

drop constraint and recreate it alter table Persion drop CONSTRAINT <constraint_name> alter table Persion add primary key (persionId,Pname,PMID) edit: you can find the constraint name by using the query below: select OBJECT_NAME(OBJECT_ID) AS NameofConstraint FROM sys.objects where OBJECT_NAME(parent_object_id)=’Persion’ and type_desc LIKE ‘%CONSTRAINT’

How to trap on UIViewAlertForUnsatisfiableConstraints?

This post helped me A LOT! I added UIViewAlertForUnsatisfiableConstraints symbolic breakpoint with suggested action: Obj-C project po [[UIWindow keyWindow] _autolayoutTrace] Swift project expr -l objc++ -O — [[UIWindow keyWindow] _autolayoutTrace] With this hint, the log became more detailed, and It was easier for me identify which view had the constraint broken. UIWindow:0x7f88a8e4a4a0 | UILayoutContainerView:0x7f88a8f23b70 | … Read more