Should i create Primary or Foreign keys first?
809712Nov 2 2010 — edited Nov 2 2010I am new to sql and a student so please bear with me.
I am creating a script so that when i run it a sequence of tables are created. I have created all my tables fine but now i want to add the primary and foreign keys. I tried to do this all in one go before but had problems, my idea was to use alter table statements and add the constraints of primary and foreign keys in that way.
The thing i want to know is what to create first? Do i do all the foriegn keys then primary keys or visa versa? Or do i do them sequentially and connect the relationships between the tables as i go. Thanks in advance!