Can you help me?

Asked

Viewed 184 times

-1

I am with a project to be done, the project itself consists of creating an sql script based on entity model and relationship, the booklet itself is not very well formulated and based on what I understood I arrived at the following script

"Our discipline revolves around the development and delivery of a project. In this project we ask that based on a model, create SQL scripts that meet the expectation of the proposal. That is, write the script for creating the three tables: Student, Enrollment and Class."

REPLY:

-- Table `mydb`.`Aluno`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Aluno` ;


CREATE TABLE IF NOT EXISTS `mydb`.`Aluno` (
  `Nr_Rgm` DECIMAL(8) NOT NULL,
  `Nm_Nome` VARCHAR(40) NULL,
  `Nm_Pai` VARCHAR(40) NULL,
  `Nm_Mae` VARCHAR(40) NULL,
  `Dt_Nascimento` DATE NULL,
  `Id_Sexo` CHAR(1) NULL,
  PRIMARY KEY (`Nr_Rgm`))
ENGINE = InnoDB;




-- -----------------------------------------------------
-- Table `mydb`.`Classe`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Classe` ;


CREATE TABLE IF NOT EXISTS `mydb`.`Classe` (
  `Cd_Classe` DECIMAL(8) NOT NULL,
  `Nr_AnoLetivo` DECIMAL(4) NULL,
  `Nr_Serie` DECIMAL(2) NULL,
  `Sg_Turma` VARCHAR(2) NULL,
  `Cd_Escola` DECIMAL(6) NULL,
  `Cd_Grau` DECIMAL(2) NULL,
  `Cd_Periodo` DECIMAL(2) NULL,
  PRIMARY KEY (`Cd_Classe`))
ENGINE = InnoDB;




-- -----------------------------------------------------
-- Table `mydb`.`Matricula`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `mydb`.`Matricula` ;


CREATE TABLE IF NOT EXISTS `mydb`.`Matricula` (
  `Nr_Rgm` DECIMAL(8) NOT NULL,
  `Cd_Classe` DECIMAL(8) NOT NULL,
  `Dt_Matricula` DATE NULL,
  `Aluno_Nr_Rgm` DECIMAL(8) NOT NULL,
  `Classe_Cd_Classe` DECIMAL(8) NOT NULL,
  PRIMARY KEY (`Nr_Rgm`, `Cd_Classe`, `Aluno_Nr_Rgm`, `Classe_Cd_Classe`),
  INDEX `fk_Matricula_Aluno1_idx` (`Aluno_Nr_Rgm` ASC),
  INDEX `fk_Matricula_Classe1_idx` (`Classe_Cd_Classe` ASC),
  CONSTRAINT `fk_Matricula_Aluno1`
    FOREIGN KEY (`Aluno_Nr_Rgm`)
    REFERENCES `mydb`.`Aluno` (`Nr_Rgm`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_Matricula_Classe1`
    FOREIGN KEY (`Classe_Cd_Classe`)
    REFERENCES `mydb`.`Classe` (`Cd_Classe`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION) 

I am using SQLFIDDLE to test the script and esmo is showing error, "ORA-00933: SQL command not properly ended" outside this error I believe q has much more because as I said q apostille does not explain very well how to make the script and this script was made based on what I understood someone can help me fix ?

1 answer

2


  • thanks for helping me

  • If the answer solved your problem, check how you accept @Wílsantos. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.