Felipe Oliveira Veríssimo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Recomeçar Autor: Felipe Oliveira Verissimo Numero: 16 Turma: Info C [toc] # Modelagem 1: Tabela de filmes > Create script ```sql= create table tb_genero ( id_genero int primary key auto_increment, ds_genero varchar(200), bt_ativo bool ); create table tb_netflix ( id_filme int primary key auto_increment, nm_filme varchar(100), id_genero int, vl_avaliacao decimal(15,2), bt_disponivel bool, dt_lancamento date, foreign key (id_genero) references tb_genero (id_genero) ); ``` > Insert script ```sql= insert into tb_genero (ds_genero, bt_ativo) values ("acao", true), ("acao suspense", true), ("terror", true); insert into tb_netflix (nm_filme, id_genero, vl_avaliacao, bt_disponivel, dt_lancamento) values ("Velozes e furiosos", 1, 6.8, true, "2001-6-22"), ("Mais Velozes Mais Furiosos", 1, 5.9, true, "2003-6-6"), ("Velozes e furiosos: Desafio em Tóquio", 1, 6, true, "2006-6-16"), ("Velozes e furiosos 4", 1, 6.6, true, "2009-4-3"), ("Velozes e furiosos 5: Operação Rio", 1, 7.7, true, "2011-5-6"), ("Velocidade furiosa 6", 1, 7, true, "2013-5-24"), ("Velozes e furiosos 7", 1, 7.1, true, "2015-4-3"), ("Velocidade furiosa 8", 1, 6.6, true, "2017-4-14"), ("Incontrolável", 2, 6.8, true, "2010-11-12"), ("Annabelle", 3, 6.4, true, "2014-10-3"); ``` > ## Alterar 2 registros da tabela > Update ```sql= update tb_netflix set id_genero = 3 where id_filme = 1; update tb_netflix set id_genero = 2 where id_filme = 3; ``` > ## Remover 2 registros da tabela > Delete ```sql= delete from tb_netflix where id_filme = 4; delete from tb_netflix where id_filme = 5; ``` > ## Consultar todos os filmes com gênero igual a Ação > Select script ```sql= select n.nm_filme from tb_netflix n inner join tb_genero g on n.id_genero = g.id_genero where ds_genero = "acao"; ``` > ## Consultar todos os filmes que possuam o nome e gênero contendo a letra a > Select script ```sql= select n.nm_filme from tb_netflix n inner join tb_genero g on n.id_genero = g.id_genero where nm_filme like "%a%" and ds_genero like "%a%"; ``` > ## Consultar todos os filmes que estejam disponíveis e com avaliação maior que 8 > Select script ```sql= select nm_filme from tb_netflix n where vl_avaliacao >= 8; ``` > ## Consultar todos os filmes que foram lançados entre 2010 e 2020 com nome de filme menor que 10 caracteres > Select script ```sql= select nm_filme from tb_netflix where length (nm_filme) < 10 and dt_lancamento between "2010-01-01" and "2020-12-31"; ``` > ## Selecionar o nome dos filmes cujo a data de lançamento for 2013 > Select script ```sql= select nm_filme from tb_netflix where dt_lancamento like "%2013%"; ``` > ## Selecionar o nome dos filmes cujo a data de lançamento for maior ou igual que 2013-1-1 > Select script ```sql= select nm_filme from tb_netflix where dt_lancamento >= "2013-1-1"; ``` > ## Selecionar o nome dos filmes cujo o gênero for terror > Select script ```sql= select n.nm_filme from tb_netflix n inner join tb_genero g on n.id_genero = g.id_genero where ds_genero = "terror"; ``` > ## Selecionar o nome dos filmes cujo o gênero for ação suspense e a data de lançamento for maior ou igual que 2006-1-1 > Select script ```sql= select n.nm_filme from tb_netflix n inner join tb_genero g on n.id_genero = g.id_genero where ds_genero = "acao suspense" and dt_lancamento >= "2006-1-1"; ``` > ## Selecionar o nome dos filmes cujo o gênero for ação e a avaliação for maior ou igual que 7.0 > Select script ```sql= select n.nm_filme from tb_netflix n inner join tb_genero g on n.id_genero = g.id_genero where ds_genero = "acao" and vl_avaliacao >= "7.0"; ``` [toc] # Modelagem 2: Tabela de alunos > Create script ```sql= create table tb_turma ( id_turma int primary key auto_increment, nm_turma varchar(255), nr_ano_letivo int, nm_curso varchar(255) ); create table tb_aluno ( id_aluno int primary key auto_increment, id_turma int, ds_sexo varchar(200), nm_aluno varchar(255), nr_chamada int, tp_status varchar(100), foreign key (id_turma) references tb_turma (id_turma) ); ``` > Insert script ```sql= insert into tb_turma (nm_turma, nr_ano_letivo, nm_curso) values ("info c", 2021, "informatica"), ("info d", 2021, "informatica"), ("indo a", 2021, "informatica"); insert into tb_aluno (id_turma, ds_sexo, nm_aluno, nr_chamada, tp_status) values (1, "masculino", "Felipe Oliveira Verissimo", 16, "presente"), (2, "masculino", "Guilherme Manso Vieira", 12, "presente"), (2, "feminino", "Barbara Barbosa dos Santos", 1, "presente"), (1, "masculino", "Erik de Almeida Benito", 14, "presente"), (3, "feminino", "Caroline da Silva Pereira", 2, "presente"), (1, "masculino", "Guilherme Oliveira Verissimo", 21, "presente"), (1, "feminino", "Beatriz Gomes Feliciano", 6, "presente"), (1, "masculino", "Eduardo Ferreira Dias", 10, "presente"), (1, "masculino", "Luis Paulo de Oliveira", 33, "presente"), (1, "feminino", "Mariana Sousa do Carmo", 37, "presente"); ``` > ## Alterar 2 registros da tabela > Update ```sql= update tb_aluno set nr_chamada = 3 where id_aluno = 1; update tb_aluno set nr_chamada = 2 where id_aluno = 6; ``` > ## Remover 2 registros da tabela > Delete ```sql= delete from tb_aluno where id_aluno = 4; delete from tb_aluno where id_aluno = 5; ``` > ## Selecionar turma, nome e chamada da tabela alunos filtrando por turma ```sql= select a.nm_aluno, a.nr_chamada, t.nm_turma from tb_aluno a inner join tb_turma t on a.id_turma = t.id_turma where nm_turma = "info c"; ``` > ## Selecionar todos campos da tabela alunos filtrando por nome e turma de forma parcial > Select script ```sql= select * from tb_aluno a inner join tb_turma t on a.id_turma = t.id_turma where nm_turma like "%info%" and nm_aluno like "%ol%"; ``` > ## Selecione ano letivo, turma, nome, chamada, sexo da tabela alunos filtrando os frequentes por turma e ano letivo. > Select script ```sql= select t.nr_ano_letivo, a.nm_aluno, t.nm_turma, a.nr_chamada, a.ds_sexo from tb_aluno a inner join tb_turma t on a.id_turma = t.id_turma where tp_status = "presente" and t.nr_ano_letivo = "2021"; ``` > ## Selecione nome, sexo da tabela alunos filtrando por ano, turma e sexo ```sql= select a.nm_aluno, a.ds_sexo from tb_aluno a inner join tb_turma t on a.id_turma = t.id_turma where nm_turma = "info c" and ds_sexo = "masculino"; ``` > ## Selecionar o nome do aluno onde o numero da chamada é maior ou igual que doze > Select script ```sql= select nm_aluno from tb_aluno where nr_chamada >= "12"; ``` > ## Selecionar o nome do aluno onde o sexo da pessoa for feminino > > Select script ```sql= select nm_aluno from tb_aluno where ds_sexo = "feminino"; ``` > ## Selecionar o nome do aluno onde o numero da chamada for menor ou igual a doze e o sobrenome do aluno conter oliveira > Select script ```sql= select nm_aluno from tb_aluno where nr_chamada <= "12" and nm_aluno like "%oliveira%"; ``` > ## Selecionar o nome do aluno onde o sobrenome conter ol e o numero da chamada for maior ou igual que trinta > Select script ```sql= select nm_aluno from tb_aluno where nm_aluno like "%ol%" and nr_chamada >= "30"; ``` > ## Selecionar o nome do aluno onde o id da turma for um > Select script ```sql= select nm_aluno from tb_aluno where id_turma = "1" ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully