Базы данных
Object-Relational Mapping
create table Student( id not null generated always as identity, -- serial -- auto_increment ... );
create sequence StudentSeq minvalue 1 maxvalue 999 start with 1 increment by 1;
insert into Students (id, ...) values (StudentSeq.nextval, ...);
select max(id) from Students;
create table Keys( name varchar(30) not null, minKey int id not null );
select minKey from Keys where name = 'Students'; update Keys set minKey = minKey + 1 where name = 'Students';
select minKey from Keys where name = 'Students'; update Keys set minKey = minKey + 100 where name = 'Students';
select * from Students where SId in (:Id1, :Id2, :Id3);
select id from Students where GroupId = 'M34391';
select * from Groups natural join Students where GroupName like 'M343%';
create table Computer( id int not null, type varchar(20) not null, departmentId int not null references Department(id), power float, personId int references Person(id), dockId int references Dock(id), displayId references Displays(id) )
create table Notebook( id int not null, departmentId int not null references Department(id), personId int references Person(id), dockId int references Dock(id) )
create table Desktop(...)
create table Mainframe(...)
create table Computer( id int not null, type varchar(20) not null, departmentId int not null references Department(id) )
create table PC( id int not null references Computer(id), personId int not null references Person(id) )
create table Notebook( id int not null references PC(id), dockId int references Dock(id) )