Created
September 8, 2009 00:32
-
-
Save antoniopassos/182640 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP TABLE IF EXISTS Equipamento; | |
DROP TABLE IF EXISTS Professor; | |
DROP TABLE IF EXISTS Reserva; | |
CREATE TABLE EQUIPAMENTO | |
( | |
idequipamento BIGINT NOT NULL, | |
categoria tinyint NOT NULL, | |
descricao varchar(60) NOT NULL, | |
dataaquisicao date, | |
preco decimal(8,2), | |
estado tinyint NOT NULL, | |
ultimaatualizacao timestamp NOT NULL, | |
constraint pk_Equipamento PRIMARY KEY(idequipamento) | |
); | |
CREATE TABLE professor | |
( | |
idprofessor BIGINT NOT NULL, | |
categoria TINYINT , | |
nome VARCHAR(45), | |
telefonefixo CHAR(9), | |
telefonecelular CHAR(9), | |
email VARCHAR(45), | |
ultimaatualizacao TIMESTAMP, | |
constraint pk_professor PRIMARY KEY(idprofessor) | |
); | |
CREATE TABLE Reserva | |
( | |
IDReserva BIGINT NOT NULL, | |
Data DATE NOT NULL, | |
HorarioInicio TIME NOT NULL, | |
HorarioFiim TIME NOT NULL, | |
Local VARCHAR(40) NOT NULL, | |
Estado SMALLINT NOT NULL, | |
fk_Professor BIGINT, | |
fk_Equipamento BIGINT, | |
constraint pk_Reserva PRIMARY KEY(IDReserva) | |
); | |
ALTER TABLE Reserva | |
ADD CONSTRAINT fk_Reserva_pk_Equipamento | |
FOREIGN KEY(fk_Equipamento) | |
REFERENCES Equipamento(IDEquipamento); | |
ALTER TABLE Reserva | |
ADD CONSTRAINT fk_Reserva_pk_Professor | |
FOREIGN KEY(fk_Professor) | |
REFERENCES Professor(IDProfessor); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment