sql - postgresql: alter table add constraint foreign key vs foreign key defined in a table -


i reading migrations of existing web app:

... create table billabletime (     id int8 not null,     ...     project int8,     primary key (id),     unique (employee, project, date) ); ... create table project (     id int8 not null,     ...     primary key (id) ); ... alter table billabletime     add constraint fk3eba06e37be2cbe     foreign key (project)     references project; 

i not understand 2 things: 1) why not use simple reference declaration

create table billabletime (     id int8 not null,     ...     project int8 references project (id),     primary key (id),     unique (employee, project, date) ); 

what benefits of method?

2) why constraint name weird: fk3eba06e37be2cbe? there reason that?

1) why not use simple reference declaration

your orm works mysql too, , mysql ignores inline foreign key declarations, you'd have long way.

there's less code support adding foreign keys when create table , adding foreign keys later.

2) why constraint name weird: fk3eba06e37be2cbe? there reason that?

it's perhaps hash of referencing , referenced table , column names. don't forget need drop foreign keys, , have name. make easier suppose.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

datatable - Matlab struct computations -