Difference between revisions of "Ds"

From Wikivyuka
Jump to: navigation, search
m
m
Line 1: Line 1:
 +
create table Vlastnik(
 +
id_vla  NUMBER PRIMARY KEY,
 +
jmenovla varchar2(25) not null,
 +
prijmenivla varchar2(25) not null,
 +
adresavla varchar2(30)
 +
);
 +
 +
insert into vlastnik values (1, 'Jan', 'Trčka', 'Frýdek-Místek');
 +
 
  create table parcela
 
  create table parcela
 
  (idParcela number primary key,
 
  (idParcela number primary key,
Line 28: Line 37:
  
 
  INSERT INTO parcela VALUES(
 
  INSERT INTO parcela VALUES(
  2,
+
  20,
 
  'ova005',
 
  'ova005',
 
  SDO_GEOMETRY( 2003,
 
  SDO_GEOMETRY( 2003,
Line 40: Line 49:
 
  idVlastnik number(6) not null,  
 
  idVlastnik number(6) not null,  
 
  idParcela number(6) not null,
 
  idParcela number(6) not null,
  odVlastni date not null,
+
  odVlastni date not null, -- datum nabyti parcely
  doVlastni date,
+
  doVlastni date, -- datum pozbyti parcely
 
  constraints vla_vla foreign key (idVlastnik) references vlastnik,
 
  constraints vla_vla foreign key (idVlastnik) references vlastnik,
 
  constraints vla_pa foreign key (idParcela) references parcela
 
  constraints vla_pa foreign key (idParcela) references parcela
 
  );
 
  );
  
  insert into vlastnictvi values(1, 1, 1, to_date('01-01-07', 'DD-MM-YY'),null);
+
  insert into vlastnictvi values(1, 2, 0, to_date('01-01-07', 'DD-MM-YY'),  to_date('01-01-08', 'DD-MM-YY'));
 +
insert into vlastnictvi values((2, 4, 0, to_date('01-01-09', 'DD-MM-YY'),to_date('01-01-11', 'DD-MM-YY'));
 +
insert into vlastnictvi values(3, 2, 0, to_date('01-01-12', 'DD-MM-YY'),null);
  
 
  select p1.cisloparcely, p2.cisloparcely, SDO_GEOM.SDO_INTERSECTION(p1.tvarparcela,  p2.tvarparcela,0.005)
 
  select p1.cisloparcely, p2.cisloparcely, SDO_GEOM.SDO_INTERSECTION(p1.tvarparcela,  p2.tvarparcela,0.005)
 
  from parcela p1, parcela p2  
 
  from parcela p1, parcela p2  
 
  where p1.cisloparcely = 1 AND p2.cisloparcely = xx;
 
  where p1.cisloparcely = 1 AND p2.cisloparcely = xx;
 +
 +
[http://gis.vsb.cz/wikivyuka/index.php/Prostorov%C3%A9_datab%C3%A1ze Zpět na stránku PDB]

Revision as of 13:34, 8 March 2012

create table Vlastnik(
id_vla   NUMBER PRIMARY KEY,
jmenovla varchar2(25) not null,
prijmenivla varchar2(25) not null,
adresavla varchar2(30)
);

insert into vlastnik values (1, 'Jan', 'Trčka', 'Frýdek-Místek');
create table parcela
(idParcela number primary key,
ku varchar2(8),
tvarParcely sdo_geometry
);
INSERT INTO parcela VALUES(
0,
'ova01',
SDO_GEOMETRY(2003,
NULL,
NULL, 
SDO_ELEM_INFO_ARRAY(1,1003,3), --obdelnik
SDO_ORDINATE_ARRAY(1,1,5,10)
)
);
INSERT INTO parcela VALUES(
1,
'bu02',
SDO_GEOMETRY(2003,
NULL,
NULL, 
SDO_ELEM_INFO_ARRAY(1,1003,3), --obdelnik
SDO_ORDINATE_ARRAY(2,6, 9.9)
)
);
INSERT INTO parcela VALUES(
20,
'ova005',
SDO_GEOMETRY( 2003,
NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1), -- polygon
SDO_ORDINATE_ARRAY(5,10 , 4,10 , 2,10 , 9,15 , 9,16 , 20,10, 5,10 )
)
);
create table vlastnictvi(
idVlastnictvi number primary key,
idVlastnik number(6) not null, 
idParcela number(6) not null,
odVlastni date not null, -- datum nabyti parcely
doVlastni date,  -- datum pozbyti parcely
constraints vla_vla foreign key (idVlastnik) references vlastnik,
constraints vla_pa foreign key (idParcela) references parcela
);
insert into vlastnictvi values(1, 2, 0, to_date('01-01-07', 'DD-MM-YY'),  to_date('01-01-08', 'DD-MM-YY'));
insert into vlastnictvi values((2, 4, 0, to_date('01-01-09', 'DD-MM-YY'),to_date('01-01-11', 'DD-MM-YY'));
insert into vlastnictvi values(3, 2, 0, to_date('01-01-12', 'DD-MM-YY'),null);
select p1.cisloparcely, p2.cisloparcely, SDO_GEOM.SDO_INTERSECTION(p1.tvarparcela,  p2.tvarparcela,0.005)
from parcela p1, parcela p2 
where p1.cisloparcely = 1 AND p2.cisloparcely = xx;

Zpět na stránku PDB