Skip to content

Instantly share code, notes, and snippets.

@xlbruce
Created September 16, 2015 00:05
Show Gist options
  • Save xlbruce/ca5391db4f9c0ac5677d to your computer and use it in GitHub Desktop.
Save xlbruce/ca5391db4f9c0ac5677d to your computer and use it in GitHub Desktop.
Sistema de emprestimo (LP3)
CREATE TABLE livro (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
nome VARCHAR(30)
);
CREATE TABLE amigo (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
nome VARCHAR(30),
telefone VARCHAR(9)
);
CREATE TABLE emprestimo (
id INT NOT NULL PRIMARY KEY GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1),
id_livro INT NOT NULL,
id_amigo INT NOT NULL
);
ALTER TABLE emprestimo ADD FOREIGN KEY (id_livro) REFERENCES livro(id);
ALTER TABLE emprestimo ADD FOREIGN KEY (id_amigo) REFERENCES amigo(id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment