358 questions
0
votes
1
answer
52
views
Check referential integrity between two GridDB containers
I have two GridDB Cloud containers participating in a one-to-many relationship. The tables layout is shown below:
Table Customer (collection container)
Name
Type
Nullity
Key
Customer_ID
INTEGER
NOT ...
0
votes
0
answers
43
views
Referential Integrity in Synthetic Data
I heard that referential integrity can be assured for one table and two tables relatively easy when generating synthetic data. With referential integrity, I e.g. mean the fact that 'London' is ...
2
votes
1
answer
165
views
Django GeneratedField as ForeignKey with referential integrity
I'm trying to create a generated field that is also a foreign key to another table, while maintaining referential integrity at the database level.
Basically, I'm trying to have the same effect as the ...
0
votes
2
answers
115
views
Triggers on parent and child table and order of execution respectively
lets say I have table A and table B. Table B is the child table and has a foreign key to table A. I have other mirrored tables, lets say table C(mirror for table A) and table D(mirror for B). Both ...
-1
votes
1
answer
260
views
How to find a referential integrity constraint via sp_fkeys? [duplicate]
I am trying to drop a table:
drop table if exists bronze.LawAggregatedPipelineSummary;
go
But there is an FK constraint on it:
Could not drop object 'bronze.LawAggregatedPipelineSummary' because it ...
0
votes
1
answer
165
views
Conditional referential integrity with PostgreSQL
Consider a basic relational pattern (one parent, multiple children)
As part of a transaction, I may delete parents, but I may also re-insert them. In the first case, I want the foreign key to become ...
1
vote
0
answers
71
views
Create a Conditional Constraint without a trigger
I would like to create a database constraint that would disallow all of the child records from being VOIDded.
For any given Transaction there can be many work orders. I want the database to prevent ...
0
votes
1
answer
279
views
Rails: How to migrate without triggering foreign key checks (referential integrity checks)?
I need to change the column type of all primary keys in all tables to the UUID format.
How do I migrate without triggering the foreign key checks?
I have tried the following 2 things below, but both ...
0
votes
0
answers
35
views
Is there a way to suppress referential integrity for specific records?
I have a table of people and another deliverers holding details of how deliveries are made. Most deliveries are made by someone in the people table so there is a peopleId which points to the people ...
0
votes
0
answers
111
views
How to maintain referential integrity in Postgres’s functions/stored procedures in light of schema changes
I don’t understand how to deal with schema changes and function definitions (which are by nature strings).
For example, if I have a table called tablename1 and/or a column called columnname1, and ...
0
votes
1
answer
178
views
How to set foreign key with compound primary key in Kdb+?
It is sufficient documents about how to set foreign key, but few about how to set with compound primary/foreign key.
I run following commands and the last 2 reported `length. How to set it correctly?
...
2
votes
1
answer
70
views
How to design MongoDB document for the hierarchical user flow?
Let us assume the following as the user flow in a multi tenant application with each tenant having its own set of catalogs or share a common catalog.
User logs into the application and see
UI with ...
0
votes
1
answer
90
views
Referential integrity sql
i hope you can help me with a general question about referential integrity.
If i am deleting data in a table that is referenced to another table as a foreign key.
How can i delete the data without ...
0
votes
2
answers
62
views
JavaScript Local Primitive Variable Re-assignment in Recursive Function
I have a recursive function like below
function dfs(row, col) {
if (grid[row][col] === 0) return true;
let result = grid[row][col] === 2;
grid2[row][col] = 0;
let up = down = left = right = ...
1
vote
1
answer
668
views
Django CheckConstraint not enforcing check on model field
I am using Django 3.2.
Backend database used for testing: sqlite3
I have a model Foo:
class Foo(models.Model):
# some fields ...
some_count = models.IntegerField()
class Meta:
...
0
votes
2
answers
857
views
Oracle - Foreign Key references different tables different schemas
I have problem with Enforcing Referential Integrity to a new table.
There are different tables in different schemas, each one has its primary key:
schema1.table1
schema2.table2
schema3.table3
I want ...
0
votes
0
answers
243
views
can't update a foreign key but i can delete it already set on CASCADE for both
I tried every solution I can find for this and non of them worked.
To explain: I'm trying to update a primary key code_class in the table classroom. This key is also a foreign key in the reservation ...
1
vote
1
answer
114
views
Insert a constraint for two columns in sql
Hi everyone I created this table for a database
CREATE TABLE IF NOT EXISTS compositions (
id INTEGER PRIMARY KEY AUTOINCREMENT,
id_product INTEGER REFERENCES products(id),
...
0
votes
0
answers
219
views
Snowflake JDBC database metadata not returning getImportedKeys
I have Java code that extracts metadata from a JDBC connection. One of the calls is to extract the imported keys. The database has the RI created, but is disabled. Is there a way to extract the ...
-1
votes
2
answers
2k
views
Self referencing table with foreign key issue
I have a small table, below is a screenshot:
There is a parent node which references back to the ID. Every row had a parent except the home page (for obvious reasons).
Here's the code with some bits ...
-5
votes
1
answer
238
views
Can referential integrity be enforced using alter table?
Is there a way to enforce referential integrity without foreign keys? Is there a way to achieve what I am trying to do below with alter table statement?
ALTER TABLE no.Man
WITH CHECK ADD CONSTRAINT ...
0
votes
1
answer
476
views
Creating tables - integrity constraints
Create the following tables:
Customer
KNr (primary key)
Name (at most 15 characters)
City (at most 10 characters)
Country (at most 10 characters)
Balance (Type FLOAT)
...
1
vote
1
answer
669
views
Many-to-Many Link Table Foreign Key Modeling in SQLite
I have the following two tables in SQLite:
CREATE TABLE `Link` (
`link_id` integer NOT NULL,
`part_id` integer NOT NULL,
CONSTRAINT `link_pk` PRIMARY KEY(`link_id`,`part_id`)
);
CREATE ...
1
vote
1
answer
44
views
Forbidding insertion of integer not in rowid in SQLite (keep directed acyclic graph table consistent)
I'd like to express:
"insertion of record with 'parent' value that is not included in 'rowid' AFTER INSERTION is forbidden."
My intention is to keep the table internally consistent as a ...
0
votes
0
answers
363
views
modify function called by check constraints
I have some CHECK constraints that all depend on a unique user defined function. They all look like this:
ALTER TABLE t_adresse ADD CONSTRAINT chkAdresse_PaysCode CHECK(LibelleCodeMatch('PAYS', ...
1
vote
1
answer
78
views
Creating a trigger not allowing a value that isn't in another column
I have a question about a trigger that I would like to create and I am not sure how to do this.
I have a table, 2017_state_data, and it contains some financial metrics per state along with said state ...
1
vote
1
answer
1k
views
Reference to one OR another table in Oracle SQL
I have one table OBRAZAC
Columns are:
JIB_OBRASCA
JIB_NARUDZBENICE
TIP_NARUDZBE
IME_ZAPOSLENOG
PREZIME_ZAPOSLENOG
JIB_KLINIKE
NAZIV_ODJELJENJA
Depending on the value in column TIP_NARUDZBE which can ...
0
votes
1
answer
1k
views
sql unique constraint with time window
I have a table where records have a (begin, end) time window of existence (for things like employement duration, birth and death, rent duration, ...)
begin IS NULL or end IS NULL if there is no bound.
...
0
votes
2
answers
235
views
Referential Integrity and Transactions in SqlAlchemy
I am attempting to insert data into two tables, the latter of which references the former. Something like:
CREATE TABLE foo (foo_id bigserial primary key, name varchar)
CREATE TABLE bar (bar_id ...
0
votes
2
answers
181
views
Checking Referential Integrity prior to Delete in APEX 20.1
When a user tries to delete a code/validation record, I would like to check to see if the code in that record has been used prior to the deletion attempt so I can display a message that is more ...
1
vote
0
answers
123
views
Complex Ref. Integrity in Oracle: child with multiple parents, non-key joins
My predecessor built our database with some "overloaded" child tables that are shared by multiple parents, using a "tabletype" column that specifies which parent table is the ...
1
vote
1
answer
653
views
Is there any way to force SQLite constrains checks?
For example, let say DB has foreign key A.b_id -> B.id with SET NULL on delete.
If record with some B.id get deleted, all b_id references will be set to NULL.
But if A already contains record where ...
0
votes
2
answers
2k
views
Why am I getting an Integrity Constraint (parent key not found) when the parent key exists
I have a parent record in my people table, but when trying to insert a matching record in my employee table, I get a integrity constraint error. Can anyone explain what is wrong?
-1
votes
1
answer
173
views
Is referential integrity commutative (i.e., is it direction-dependent)?
I've had some behavior in MS Access 2019 that surprised me and I've boiled it down to the following:
I've got two tables with a different number of records:
I need to establish an outer join between ...
-1
votes
1
answer
2k
views
Integrity constraint violated - Parent key not found
I am creating two tables each having one primary key column and another column that is used to link both tables using a foreign key.
create table t1(a number not null primary key,
b ...
1
vote
2
answers
323
views
Ensure there's exactly one foreign key reference from a set of tables
I'm trying to design a database structure that allows me to extract common fields into one table called "entity".
You could think of "entity" as an abstract class. Every "...
0
votes
1
answer
353
views
Is there a way to define the relationship between 2 tables using 2 non-unique columns columns using SQL
During a practical interview exercise on databases I was given 2 files in CSV one for drug dispensation showing unique instances of patient (the patient_id column is unique) accessing medicine with ...
1
vote
1
answer
96
views
mySQL repair new database integrity implementing foreign keys
My problem is fairly simple. I was been given around 95% of a fairly large, working data set. And I wrote out a parser, set my data out into CSVs, wrote my bulk loads, and have everything set up save ...
-2
votes
1
answer
426
views
Reference different tables depending on a condition
I have a table [Advertiser] and a table [Ad] that has a N..M relationship that an Advertiser can have many Ads so that [Ad] will have a column referncing [Advertiser].
An Advertiser can either be a ...
0
votes
0
answers
199
views
SQLAlchemy IntegrityError Relationship using object already in the database
This is my model, made with classical mapping, classes A and B are working accordingly
import sqlalchemy as sa
from sqlalchemy.orm import mapper, relationship
from domain.a import A
from domain.b ...
0
votes
0
answers
287
views
Use table force drop when you have two tables refrencing each other
I created table A and table B
I am using SQL Server and I got this error message:
Msg 3726, Level 16, State 1, Line 4
Could not drop object 'a' because it is referenced by a FOREIGN KEY constraint.
...
0
votes
0
answers
37
views
how do we maintain referential integrity without using primary key and foreign key
i have created function like below, but showing error. any ideas are welcome.
CREATE FUNCTION `CheckFunction`() RETURNS varchar(36)
BEGIN
RETURN (select DISTINCT column from table);
END
Error: Error ...
0
votes
1
answer
262
views
Laravel 7 Migration - Foreign Key created but its constraint code not working
I cannot seem to figure out why my PK and FK of the same exact type are not linked in Laravel. Both tables are InnoDB. The foreign key in the second screenshot shows that I can enter any integer even ...
1
vote
1
answer
40
views
Which type of iterable/list in Python is able to structurally share the same items from previous iterables/lists?
Say I have two long lists a and b and want a list c:
a = [obj1, obj2, ..., objN]
b = [objNplus1, objNplus2, ..., objNplusM]
c = a + b
How can I create a new list that shares the previous ones as its ...
-1
votes
2
answers
809
views
PostgreSQL - NULL References
I have a data model for Tasks and Equipments.
Sometimes a Task needs some Equipment to be completed, sometimes it doesn't.
Task table
create table task (
id serial primary key
, task_name ...
0
votes
1
answer
47
views
RDBMS Ref. Integrity: A child with too many parents?
I have a general design question. Consider these 3 tables:
Table Restaurants:
RID pk auto_increment
etc...
Table Vacations:
VID pk auto_increment
etc...
Table Movies:
MID pk ...
0
votes
0
answers
154
views
How do I enforce referential integrity on a database field conditional upon another field in the referencing table?
First of all, I hope whoever reads this is well at these difficult times.
I am trying to code a database using MariaDB/MySql that can manage inventory and groups of business transactions.
I have an ...
-1
votes
3
answers
2k
views
How to establish referential integrity constraint?
1 create table pointofinterest(
2 pointid number not null,
3 describe varchar(30),
4 opentime varchar(30),
5 closetime varchar(30),
6 townid varchar(30),
7 constraint pk ...
0
votes
2
answers
197
views
Modeling optional properties of an Entity, based on a mutable discriminator in a parent Entity
I am having a hard time getting a relational model out of my project's requirements.
The general context is about devices posting sensor data.
In the table representations, the PKs of each table ...
-1
votes
1
answer
681
views
Microsoft Access Referential Integrity Error Message but Primary Key Values Match
I am working on appending some additional data from an Excel spreadsheet to an existing Microsoft Access database. The primary key is "RecordID", however, when I go to create the one-to-one ...