Quantcast
Channel: Active questions tagged referential-integrity - Database Administrators Stack Exchange
Browsing all 59 articles
Browse latest View live

What is the correct way to map relationships between structurally similar...

I'm working on the usual comments table in postgres that has a one-to-many relationship with a commentable entity. In other words, one comment belongs to a post, and a post can have many comments.The...

View Article



Does SQL manage foreign key constraints in terms of insertion?

Say I have a table tbl1 with data A1 and A2, where A1 is the primary key. Then I have another table tbl2 with data A3 and A1, both together being the primary key, referencing A1 as a foreign key from...

View Article

Enforcing constraints "two tables away"

I ran into some trouble modeling an electrical schematic in SQL.The structure I'd like to capture is part ←────────── pin↑↑part_inst ←───── pin_instwhere "inst" is short for "instance".For example, I...

View Article

How do I identify tables that have a foreign key to a specific table in Sybase?

I am looking for (preferably) an SQL statement that selects the table/and column names for any table with a foreign key to a given table in Sybase. I think it should be somehow possible with the sys......

View Article

Differences between MATCH FULL, MATCH SIMPLE, and MATCH PARTIAL?

I've noticed a MATCH SIMPLE and MATCH FULL, but I don't understand what they do. I see default is MATCH SIMPLE; but, how do the other MATCH clauses to the FOREIGN KEY constraint function?

View Article


How to model very flexible referencing relationships between many tables?

I have various different entity types in my database. For purposes of example, consider an IMDB database:MoviePersonActorDirectorTranslationand 20 more tablesMy application enables free-form many-many...

View Article

Image may be NSFW.
Clik here to view.

More than one path between M-M tables

I'm trying to figure out if it is bad practice to have more than one path between tables that are related via many-to-many relationships.I have 3 user-facing tables: Dupe, Cue, and Take. There is a...

View Article

How do I prove that the act of removing foreign keys doesn't corrupt existing...

TL;DR: Prove that in practice, the execution of the alter table table_name drop foreign key constraint_name statement does not corrupt existing data. The important consideration is the execution of the...

View Article


Referential integrity based on data more than a table away

Notes on tables A, B, C, D, EB.aid and C.aid reference A.aid.D.cid references C.cid and D.did is the primary key. D is a C.cid and did are pre-assigned and I cannot change them (they need to remain...

View Article


Image may be NSFW.
Clik here to view.

Complex Delete Cascade Including Self-Referencing Table

Above is a diagram of my data structure. It represents a hierarchy which can contain three different types of "elements": "A"s, "B"s and "C"s. The relationships show the delete cascade behavior I would...

View Article

Image may be NSFW.
Clik here to view.

Hierarchical references abstraction with strict model

I want to abstract a real world hierarchy in a strict DB model (as strict as possible).My problem is to to create a structure with a this-or-this-but-not-both rules set.I have two entity types,Device,...

View Article

Data Deplucation and relationship integrity [closed]

I apologize in advance as this question is likely to be more on the theoretical side, with (hopefully) a fair bit of discussion.This is the scenario: We have Salesforce and a multiple local...

View Article

two-table-over functional relationship: maintaining referential integrity

I have three tables, the last two having a many to one relationship with the first, written here in SQL:create table study ( id bigint primary key, name text);create table treatment ( id bigint primary...

View Article


DELETE statement conflicted with the REFERENCE constraint

My situation looks like this:Table STOCK_ARTICLES:ID *[PK]*OTHER_DB_IDITEM_NAMETable LOCATION:ID *[PK]*LOCATION_NAMETable WORK_PLACE:ID *[PK]*WORKPLACE_NAMETable INVENTORY_ITEMS:ID...

View Article

Foreign key constraints check during replication?

I am a little bit new to replication and can't seem to find an answer to this anywhere. Let's say I have a simple relation in my database: Department table with Code column as PK and Person table...

View Article


Foreign key twice in same table for different columns?

Server: MariaDB 10.3.21Client: MariaDB 10.4.12Given the following structure/data:DROP TABLE IF EXISTS `main`;CREATE TABLE `main` ( `name` varchar(100) COLLATE utf8mb4_unicode_ci NOT NULL, `description`...

View Article

Better way to ensure referential integrity of one column to a composite...

Given a first table CREATE TABLE table1 ( column1 INTEGER, column2 TEXT, PRIMARY KEY (column1, column2));does SQL have an idiomatic way to constrain column3 in a second tableCREATE TABLE table2 (...

View Article


Is there another source for untrusted foreign keys beside FK disable and BULK...

This question and its answer explain how bulk inserts will render FK as untrusted, as bulk inserts are not completely checked (only PK and UNIQUEs) . I also know that temporarily disable of a FK may...

View Article

Image may be NSFW.
Clik here to view.

Referential Integrity - Indirect Foreign Key In "Depth"

QuestionWhat is the best practice for ensuring a Key from a "Grand-Parent" or "Great Grand-Parent" table is maintained when a "Child" or "Grand-Child" table is created from multiple relationship...

View Article

Ensure integrity of other columns from foreign record

I have 3 tables:Race - id PKRacer - id PK - rankWinner - id PK - race_id FK(Race.id) - racer_id FK(Racer.id) - rank - prize UNIQUE CONSTRAINT (race_id, rank)Racer.rank is a non-unique values, as some...

View Article
Browsing all 59 articles
Browse latest View live




Latest Images