CREATE SCHEMA `Shapes`;
USE `Shapes`;

--
-- Table structure for table `Shape`
--
CREATE TABLE `Shape` (
  `shapenumber` int(11) NOT NULL AUTO_INCREMENT,
  `color` varchar(45) NOT NULL,
  PRIMARY KEY (`shapenumber`)
) ;
--
-- Table structure for table `Circle`
--
CREATE TABLE `Circle` (
  `shapenumber` int(11) NOT NULL,
  `radius` decimal(6,2) NOT NULL,
  `xcoordinate` decimal(6,2) NOT NULL,
  `ycoordinate` decimal(6,2) NOT NULL,
  PRIMARY KEY (`shapenumber`),
  KEY `fk_Circle_Shape_idx` (`shapenumber`),
  CONSTRAINT `fk_Circle_Shape` FOREIGN KEY (`shapenumber`) REFERENCES `Shape` (`shapenumber`)
) ;
--
-- Table structure for table `Rectangle`
--
CREATE TABLE `Rectangle` (
  `shapenumber` int(11) NOT NULL,
  `length` decimal(6,2) NOT NULL,
  `width` decimal(6,2) NOT NULL,
  `xcoordinate` decimal(6,2) NOT NULL,
  `ycoordinate` decimal(6,2) NOT NULL,
  PRIMARY KEY (`shapenumber`),
  KEY `fk_Rectangle_Shape_idx` (`shapenumber`),
  CONSTRAINT `fk_Rectangle_Shape` FOREIGN KEY (`shapenumber`) REFERENCES `Shape` (`shapenumber`)
) ;
--
-- Table structure for table `Point`
--
CREATE TABLE `Point` (
  `xcoordinate` decimal(6,2) NOT NULL,
  `ycoordinate` decimal(6,2) NOT NULL,
  PRIMARY KEY (`xcoordinate`, `ycoordinate`)
);

insert into Shape(color) values ('green');
insert into Shape(color) values ('gray');
insert into Shape(color) values ('yellow');
insert into Shape(color) values ('red');
insert into Shape(color) values ('black');
insert into Shape(color) values ('blue');
insert into Shape(color) values ('purple');

insert into Circle values (1, 5, 3, 4);
insert into Circle values (2, 6, 5, -4);
insert into Circle values (3, 3.5, 2.7, -4.5);
insert into Circle values (4, 5.85, 3.23, 4.34);

insert into Rectangle values (5, 5, 4, 3, 4);
insert into Rectangle values (6, 6, 2, 5, -4);
insert into Rectangle values (7, 3.5, 2.6, 2.7, -4.5);

insert into Point values (0, 0);
insert into Point values (2, 1);
insert into Point values (-1, -2);

CREATE USER 'userShapes'@'localhost' IDENTIFIED BY 'userShapesPW';
GRANT ALL PRIVILEGES ON Shapes . * TO 'userShapes'@'localhost';
