在不带外键的关系表中添加列Hibernate

在不带外键的关系表中添加列Hibernate,hibernate,postgresql,Hibernate,Postgresql,我使用两个表,即seller和product,我使用一个称为seller product的关系表来关联这个表,其中我是seller id和product id,它们是外键,我需要添加另一列作为rate,它不是外键,我可以这样做吗。我正在使用PostgreSQL。只需添加以下列: alter table seller_product add rate integer; 假设您已经创建了表,例如,使用: create table seller_product ( seller_id inte

我使用两个表,即seller和product,我使用一个称为seller product的关系表来关联这个表,其中我是seller id和product id,它们是外键,我需要添加另一列作为rate,它不是外键,我可以这样做吗。我正在使用PostgreSQL。

只需添加以下列:

alter table seller_product add rate integer;
假设您已经创建了表,例如,使用:

create table seller_product
(
   seller_id integer not null references seller,
   product_id integer not null references product,
   primary key (seller_id, product_id)
);
要在创建表时一起执行所有操作,请执行以下操作:

create table seller_product
(
   seller_id  integer not null references seller,
   product_id integer not null references product,
   rate       integer,
   primary key (seller_id, product_id)
);

请您添加一些代码,并指定您尝试过的内容,以便我们能更好地帮助您。。