Skip to content

Instantly share code, notes, and snippets.

@rofr
Created September 16, 2015 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rofr/ab2f647d6eab31b28543 to your computer and use it in GitHub Desktop.
Save rofr/ab2f647d6eab31b28543 to your computer and use it in GitHub Desktop.
/*
drop table Shape;
drop table Drawing;
drop table ShapeType;
*/
create table Drawing (
DrawingId int not null primary key,
Name varchar(100)
);
create table ShapeType (
ShapeTypeId int not null primary key,
Name varchar(50) not null
);
create table Shape (
DrawingId int not null references Drawing(DrawingId),
ShapeId int not null,
TypeId int not null references ShapeType(ShapeTypeId), --1,2,3
X int,
Y int,
Height int,
Width int
);
alter table Shape add constraint PK_Shape primary key (DrawingId, ShapeId);
insert into ShapeType values(1,'Circle');
insert into ShapeType values(2,'Rectangle');
insert into ShapeType values(3,'Square');
insert into ShapeType values(4,'Triangle');
insert into drawing values(1, 'Roberts drawing');
insert into Drawing values(2, 'Neos drawing');
insert into Shape values(1,1,1,0,0,10,10);
insert into Shape values(1,2,2,10,10,20,20);
insert into Shape values(1,3,3,20,20,30,30);
insert into Shape values(1,4,4,30,30,40,40);
insert into Shape values(2,1,1,100,100,50,50);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment