NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

create table funcionario(
idfuncionario INT UNSIGNED NOT NULL AUTO_INCREMENT,
nome varchar (100) not null,
cargo varchar (50) not null,
primary key (idfuncionario)
);


insert into funcionario (nome, cargo) values ('andre teste', 'Gerente');


CREATE TABLE servico(
idservico INT UNSIGNED NOT NULL AUTO_INCREMENT,
descricao VARCHAR(95) NOT NULL,
local VARCHAR(45) NOT NULL,
dataAbertura DATETIME NOT NULL,
dataFechamento DATETIME NOT NULL,
status VARCHAR(10) NOT NULL,

PRIMARY KEY (idservico)
);


ALTER TABLE servico
ADD FOREIGN KEY (`idservico`) REFERENCES `funcionario`(`idfuncionario`);

INSERT INTO servico (descricao,local,dataAbertura,dataFechamento,status)
VALUES ('reparo da porta','Quarto 102','2023-10-03 09:15:00','2023-12-03 09:00:00','aberto');


SELECT `funcionario`.`nome`,`funcionario`.`cargo`,`servico`.`descricao`,`servico`.`local`,`servico`.`dataAbertura`, `servico`.`status`
FROM `empresa`.`funcionario`
INNER JOIN `empresa`.`servico`
ON `idfuncionario` = `idservico`;
CREATE DATABASE BibliotecaSENAC;
USE BibliotecaSENAC;
CREATE TABLE Livro (
LivroID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Titulo VARCHAR(255) NOT NULL,
Autor VARCHAR(255) NOT NULL,
Genero VARCHAR(100) NOT NULL,
DataPublicacao DATE NOT NULL,
Preco DECIMAL(10, 2) NOT NULL,
PRIMARY KEY (LivroID)
);
CREATE TABLE Aluno (
AlunoID INT UNSIGNED NOT NULL AUTO_INCREMENT,
Nome VARCHAR(255) NOT NULL,
Endereco VARCHAR(255) NOT NULL,
Email VARCHAR(100) NOT NULL,
DataCadastro DATE NOT NULL,
PRIMARY KEY (AlunoID)
);
CREATE TABLE Emprestimo (
EmprestimoID INT UNSIGNED NOT NULL AUTO_INCREMENT,
LivroID INT UNSIGNED NOT NULL,
AlunoID INT UNSIGNED NOT NULL,
DataEmprestimo DATE NOT NULL,
DataDevolucao DATE,
PRIMARY KEY (EmprestimoID),
FOREIGN KEY (LivroID) REFERENCES Livro(LivroID),
FOREIGN KEY (AlunoID) REFERENCES Aluno(AlunoID)
);
INSERT INTO Livro (Titulo, Autor, Genero, DataPublicacao, Preco) VALUES
('1984', 'George Orwell', 'Distopia', '1949-06-08', 29.90),
('O Senhor dos Anéis', 'J.R.R. Tolkien', 'Fantasia', '1954-07-29', 59.90),
('Dom Casmurro', 'Machado de Assis', 'Romance', '1899-12-01', 19.90),
('A Revolução dos Bichos', 'George Orwell', 'Satira', '1945-08-17', 24.90),
('O Pequeno Príncipe', 'Antoine de Saint-Exupéry', 'Infantil', '1943-04-06', 15.90);
INSERT INTO Aluno (Nome, Endereco, Email, DataCadastro) VALUES
('Alice Santos', 'Rua das Flores, 123', '[email protected]', '2024-06-01'),
('Bruno Lima', 'Avenida Paulista, 456', '[email protected]', '2024-06-02'),
('Carla Souza', 'Rua das Palmeiras, 789', '[email protected]', '2024-06-03'),
('Daniel Costa', 'Avenida Brasil, 101', '[email protected]', '2024-06-04'),
('Elena Ribeiro', 'Rua dos Pinheiros, 202', '[email protected]', '2024-06-05');
INSERT INTO Emprestimo (LivroID, AlunoID, DataEmprestimo, DataDevolucao) VALUES
(1, 1, '2024-06-10', '2024-06-17'),
(2, 2, '2024-06-11', '2024-06-18'),
(3, 3, '2024-06-12', '2024-06-19');
4. Consultar os Dados Inseridos
Consulta SQL para unir dados de livros e alunos através da tabela Emprestimo
sql
Copiar código
SELECT
Aluno.Nome AS AlunoNome,
Livro.Titulo AS LivroTitulo,
Emprestimo.DataEmprestimo,
Emprestimo.DataDevolucao
FROM
Emprestimo
INNER JOIN
Aluno ON Emprestimo.AlunoID = Aluno.AlunoID
INNER JOIN
Livro ON Emprestimo.LivroID = Livro.LivroID;
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.