Best practice for foreign key column position in table

This may be a dumb question, but here goes:

Is there a standard or best practice that indicates in what order the foreign key columns should be in the table?

I for one, as a PC idea, is the first column in the table, followed by all foreign keys, and then the columns related to this table.

Another way to do this is to have PK as the very first column, then all supporting columns, and then all foreign keys ...

I think it really doesn’t matter, but I would like to get a standard in my organization for this ...

+5
source share
6 answers

, , " " , .

, "".

+1

, , , . , - , .

, _fk - .

, vehicle_id vehice_id_fk .

+3

, PK, , . DRL ; . , , , , . _fk _key _id , .

+2

DRL. , , . , db (PK, FK ..).

+2

, . " ".

, , - ? ? , ? , .

, , , , . , .

+1

. , (, , ):

  • NOT NULL .
  • NOT NULL ,
  • NULLable, , ,
  • , , . ( MOD_TIMESTAMP, .)

- .

ERD , .

, , - . VEHICLE_ID_FK. VEHICLE_ID VEHICLE . VEHICLE_ID, , COPS_VEHICLE_ID ROBBERS_VEHICLE_ID.

+1

All Articles