Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Desafio banco de dados Hugo #5

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

hugoogle
Copy link

No description provided.

Copy link
Member

@vueda vueda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deixei algumas observações, mas no geral está atendendo bem ao desafio proposto.
Parabéns!

`DATA_DE_PUBLICACAO` DATE NULL,
`QUANTIDADE_DE_PAGINA` INT NULL,
`IDIOMA` ENUM('PORTUGUES', 'INGLES', 'ESPANHOL') NOT NULL,
`AUTOR_KEY` BIGINT NOT NULL NULL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

O livro pode ter mais de um autor. Isso poderia ser feito com uma tabela tipo LIVRO_AUTOR por exemplo.

@@ -0,0 +1,44 @@

-- Insert Tabale Autoria
INSERT INTO `AUTOR` VALUES (null,'Furgeri', ' Bates', '2000-08-25' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Em insert geralmente é bom definir os nomes das colunas pra evitar problema caso alguma coisa afete a ordem. Tipo INSERT INTO MINHA_TABELA(ID, NOME) VALUES (1,2)

FROM EMPRESTIMO EM
INNER JOIN LIVRO LI ON EM.ISBN = LI.ISBN
Where EM.DATA_DE_RETIRADA
BETWEEN TIMESTAMP(DATE_SUB('2020-10-01', INTERVAL 7 day)) AND '2020-10-01'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dá pra fazer um DATA_DE_RETIRADA >= (NOW() - INTERVAL 7 DAY) pra pegar sempre os últimos 7 dias.

order by EM.DATA_DE_RETIRADA ASC;

-- Todos os livros que contém a palavra 'java' na descrição (Independente de maiúsculas ou minúsculas).
SELECT TITULO AS LIVRO FROM LIVRO WHERE TITULO LIKE '%java%';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

É bom fazer um lower(titulo) porque o comportamento aqui pode ser diferente de acordo com o banco de dados. Com o lower você garante que vai estar sempre comparando no mínusculo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants