主键共享:
共生共灭
主外键关联:(将外键强制声明为unique,间接实现一对一)
主键生成器:
单行单列单值表
Student
Computer
。。。
单行多列单值表
create table o2o_id(
sid number,
cid number
);
insert into o2o_id values(1,1);
IdGenerator:
select --- from o2o_id;
update o2o_id set --- = --- +1;
Student : sid = IdGenerator.getNewId("o2o_id","sid");
Computer: cid = IdGenerator.getNewId("o2o_id","cid");
alter table o2o_id add aid number;
insert into o2o_id(aid) values(1);
Address: aid = IdGenerator.getNewId("o2o_id","cid");
一对多:
student 1------1 computer n---------1 classroom
Set中如果需要让系统自动去除重复对象,
要求自定义对象必须覆盖hashCode方法以及equals方法
hashCode方法目的是要保证属性值相同的对象,hashCode方法的返回值也必须一样