I have some problems about db2 foreign keys.
I need to learn how to get foreign keys with table name,referential table name and column names in DB2.
Thanks a lot !
Related
A developer I work with insists on maintaining a foreign key constraint in a database (MySQL) where the tables containing the related data are read only. How do I politely tell him this is unnecessary?
Say I have 3 tables (or Python classes):
Two tables contain primary keys and so are LOOKUP tables.
Another table (say table X) contains both foreign keys from the first 2 tables along with some more primary keys.
Is it possible to upload data directly into table X in Django? If so, would the primary keys automatically inherit these data values?
I am working on a Django project with a database in PostgreSQL. During my schema design, I have noticed that one table is referencing many foreign keys from other tables. Just curious that how many foreign keys can be referenced from/to one table? I also searched and found that the SQL server 2014 can reference up to253 foreign keys.
I don't think there is a hard limit. I just created a table with 10001 foreign key constraints.
Of course that doesn't mean that it is sane to define that many foreign keys, and performance will suffer considerably.
I'm trying to setup a new server with foreign tables (using postgres_fdw) that weren't foreign tables previously, and I have some OneToOneFields pointing to these tables. This doesn't work out of the box - OneToOneFields use foreign keys, and postgres_fdw does not support foreign keys for foreign tables.
The foreign tables are in a read-only database on the same server.
Is there an easy way to get this working?
After a little more research, I think the answer is 'don't do that'. Handling foreign keys for foreign tables isn't implemented, and any solution that tried to bridge that gap would have serious performance and/or consistency issues.
pglogical looks like a better solution - instead of pulling the data in through postgres_fdw, replicate the tables into the new database so they're local. There are other projects for replicating just specific tables, but pglogical is included with PostgreSQL 10.
Is it possible to use a mysql table transparently though the table is an alias for a table in a foreign database?
The standard doesn't support it, neither implementation of mysql db.