Im having some problems making an sql script that should implement my database... Im getting several errors when i try to run the script, the problem is the primary and foreign keys.... In some tabels i want to use a foreign key as primary key, how is this working? I have attached my sql script for you to see......
Let me first state..im not a DBA, im just getting around learning this sql stuff but i think you can only have one primary key per table.
What is the reason you want to have 4 primary keys in on table? Uniquenes of the data for those rows?
Why are you using columns that already excist in another table? For joins, one foreign key is enough (to establish a relation between tables).
Another thing that struck me, is that you are using VARCHAR as a primary key.
From what i've 'heard', using varchar as a primary key is not such a good idea from 'index' pov. You'd better make a <columname>_ID integer and either use SERIAL or sequence (which should be created).
I tried to make a sample of what would be in my mind better, but as i only write dutch and english, i cannot "visualize" what table- and columnnames we are talking about.
Feel free to correct me on points that are not (entirely) correct.