(IIRC it MyISAM BDB), , .
create table component_core (
component_id int auto_increment,
primary key(component_id)
);
create table component_history (
component_id int not null,
version_id int auto_increment,
data varchar(20),
version_start_date datetime not null,
version_end_date datetime not null,
primary key(component_id,version_id)
);
component_core , _ component_history version_id 1 _. _ __, version_id . auto_increment MAX (auto_increment_column) + 1 WHERE component_id = given-component_id.
Insert a new component_core
Retrieve the last autoincremented value from component_core (1)
Insert a new component_history using the component_id from component_core
Insert a new component_history using the same component_id
Insert a new component_history using the same component_id
Insert a new component_core
Retrieve the last autoincremented value from component_core (2)
Insert a new component_history using the component_id from component_core
Insert a new component_history using the same component_id
component_core
component_id
1
2
component_history
component_id version_id
1 1
1 2
1 3
2 1
2 2
, - , ( , MyISAM, MyISAM)
: http://dev.mysql.com/doc/refman/5.1/en/example-auto-increment.html