LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Fascinating PostgreSQL foreign keys problem (https://www.linuxquestions.org/questions/programming-9/fascinating-postgresql-foreign-keys-problem-9770/)

Bert 12-07-2001 05:20 AM

Fascinating PostgreSQL foreign keys problem
 
I've made up some foreign keyed tables referring to a to table with only one primary key (a unique membership number).

I've populated the first table but it won't let me populate the foreign-keyed tables - (with the matching data of course).

Does anyone know why? SQL books and the PostgreSQL tutorial certainly don't!

thanks

Bert

Bert 12-11-2001 07:08 AM

Whoever named SQL 'Structured Query Language' must have been joking. It is without a doubt the most unstructured joke of a language I've ever come across! :p

The solution to the problem above is this:

1. Make your tables, with primary keys.
2. do an
ALTER TABLE myTable ADD FOREIGN KEY FKey1 REFERENCES myOtherTable

before you INSERT into the tables.

In other words, make the table then change it to do something you should be able to do first time round but can't.

Another way is to insert ALL of the attributes into a HUGE parent table and foreign key everything from that!

Normalisation? Database efficiency? Hey who needs it when you have UQL - Unstructured Query Language!


All times are GMT -5. The time now is 10:00 AM.