iLucas
    • 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
    # Super Bônus Sql autor: Lucas Bezerra Sampaio - info A [toc] ## Modelagem 1: Catálogo Loja Apps > Create Script ```sql= create table tb_apps ( id_apps int primary key auto_increment, nm_nome varchar(200), tp_genero varchar(100), bt_disponivel_na_apple_store bool, bt_disponivel_na_google_play bool, nm_criador varchar(100), qtd_total_dowloads int, vl_avaliação decimal(10,2), qtd_tamanho int, dt_ultima_atualização date ); ``` > Insert Script ```sql= insert into tb_apps (nm_nome, tp_genero, bt_disponivel_na_apple_store, bt_disponivel_na_google_play, nm_criador, qtd_total_dowloads, vl_avaliação, qtd_tamanho, dt_ultima_atualização) values ('clash royale', 'jogo', true, true, 'supercell', 300000000, 4.2, 500, '2021-03-26'), ('among us', 'jogo', true, true, 'innersloth LLC', 1000000000, 3.9, 542, '2021-03-30'), ('ifood delivery de comida e mercado', 'aplicativo', true, true, 'ifood delivery de comida e mercado', 5000000, 4.8, 28, '2021-04-01'), ('soccer stars', 'jogo', true, false, 'miniclip.com', 50000000, 4.2, 59, '2021-03-29'); ``` > Select Script ```sql= -- Consulta por apps que são diferentes de jogos select * from tb_apps where tp_genero <> 'jogos'; -- Consulta por apps que são disponíveis na app store e indisponiveis na play store select * from tb_apps where bt_disponivel_na_apple_store = true and bt_disponivel_na_google_play = false; -- Consulta por Nomes de apps que contém a letra A select*from tb_apps where nm_nome like 'A%'; ``` ## Modelagem 2: Países >Create Script ```sql= CREATE TABLE tb_paises ( id_paises int primary key auto_increment, nm_nome varchar(200), ds_sigla varchar(200), qtd_populacao long, nr_area varchar(200), dt_data_aniversario date, ds_pib varchar(200), nm_continente varchar(200), nm_capital varchar(200), ds_idiomas varchar(200) ); ``` > Insert Script ```sql= insert into tb_paises (nm_nome, ds_sigla, qtd_populacao, nr_area, dt_data_aniversario, ds_pib, nm_continente, nm_capital, ds_idiomas) values ('Brasil', 'Br', 212000000, '8.516.000 km²', '1500-04-22', '1,84 trilhão USD', 'America do Sul', 'Distrito Federal', 'Português e A lingua Brasileira de Libras'), ('Finlândia', 'FI', 5518000, '338.440 km²', '1917-12-06', '269,3 bilhões USD', 'Continente Europeu', 'Helsinque', 'Finlandês e Sueco'), ('Angola', 'AO', 31830000, '1.247.000 km²', '1975-11-11', '88,82 bilhões USD', 'África', 'Luanda', 'Português'); ``` > Select Script ```sql= -- Consulta por indenpendencia maior que 1900. select * from tb_paises where dt_data_aniversario > '1900-01-01'; -- Consulta por países que o pib está em bilhões select * from tb_paises where ds_pib = 'bilhões'; -- Consulta por países que estão na américa do sul select * from tb_paises where nm_continente = 'América do sul'; ``` ## Modelagem 3: Clube de Futebol > Create Script ```sql create table tb_clubes_futebol( id_futebol int primary key auto_increment, nm_nome varchar(255), ds_sigla varchar(200), nm_pais varchar(200), nm_cidade varchar(200), dt_data date, ds_total_titulos int(200), nm_presidente varchar(200), qtd_capacidade_estadio int(200), nm_estadio varchar(200) ); ``` > Insert Script ```sql= insert into tb_clubes_futebol(nm_nome, ds_sigla, nm_pais, nm_cidade, dt_data, ds_total_titulos, nm_presidente, qtd_capacidade_estadio, nm_estadio) values ('Santos Futebol Clube', 'SFC', 'Brasil', 'Santos', '1912-04-14', 305, 'Andrés Rueda', 16899, 'Urbano Caldeira'), ('Clube Atlético Mineiro', 'CAM', 'Brasil', 'Minas Geriais', '1908-03-25', 100, 'Sérgio Coelho', 62000, 'Mineirão'), ('Futbol Club Barcelona', 'FCB', 'Espanha', 'Catalunha', '1889-11-29', 100, 'Joan Laporta', 99000, 'Camp Nou'); ``` > Select Script ```sql= -- Consulta por time que possuem mais de 300 titulos Select * from tb_clubes_futebol where ds_total_titulos > 300; -- Consulta por times que o país é diferente de Brasil. Select * from tb_clubes_futebol where nm_pais <> 'Brasil'; -- Consulta por times que a capacidade do estadio for maior que 20 mil. Select * from tb_clubes_futebol where qtd_capacidade_estadio > 20000; ``` ## Modelagem 4: Músicas. > Create Script ```sql= create table tb_musica ( id_musica int primary key auto_increment, nm_nome varchar(100), nm_artista varchar(100), nm_album varchar(100), ds_genero varchar(100), ds_duracao time, qtd_likes int, qtd_views long, dt_lancamento date ); ``` > Insert Script ```sql= Insert into tb_musica(nm_nome, nm_artista, nm_album, ds_genero, ds_duracao, qtd_likes, qtd_views, dt_lancamento) values ('Baby Shark', 'PinkFong','BabyShark Músicas','POP','02:16', 20000000, 8342645272, '2016-06-17'), ('Bohemian Rhapsody', 'Queen','A Night at the Opera', 'Rock', '05:54',8800000,1000000000,'1975-11-21'), ('The Nights', 'Avicii', 'The Nights', 'Eletrônica', '03:10', 6300000, 600000000, '2014-12-15'); ``` > Select Script ```sql= -- Consulta por músicas que no nome não tenha a letra A select * from tb_musica where nm_nome not like '%A%'; -- Consulta por músicas onde os likes são maiores que 2 milhões e views maior que 100 milhões select * from tb_musica where qtd_likes > 2000000 and qtd_views > 100000000; -- Consulta por músicas onde a data de lançamento foi depois dos anos 2000. select * from tb_musica where dt_lancamento > '2000-01-01'; ``` ## Modelagem 5: Modelagem Concessionária > Create Script ```sql= create table tb_carro ( id_carro int primary key auto_increment, nm_modelo varchar(100), nm_marca varchar(100), dt_ano_fabricacao date, dt_ano_modelo date, ds_cor varchar(100), vl_preco decimal(10,2), ds_kilometragem int, bt_possui_ar_condicionado bool, bt_possui_direcao_hidraulica bool ); ``` >Insert Script ```sql= insert into tb_carro (nm_modelo, nm_marca, dt_ano_fabricacao, dt_ano_modelo, ds_cor, vl_preco, ds_kilometragem, bt_possui_ar_condicionado, bt_possui_direcao_hidraulica) Values ('corolla', 'toyota motor', '2021-01-01', '2010-10-28', 'preto', 1250000.00, 0, true, true), ('zafira', 'chevrolet', '2017-04-02', '2009-04-02', 'branco', 60000.00, 250, true, true); ``` > Select Script ```sql= -- Consulta por carros que possuem direção hidráulica. select * from tb_carro where bt_possui_direcao_hidraulica = true; -- Consulta por carros que possuem uma kilometragem maior ou igual a 200. select * from tb_carro where ds_kilometragem >= 200; ``` ## Modelagem 6: Computadores > Create Script ```sql= create table tb_computador ( id_computador int primary key auto_increment, vl_preco decimal, ds_tamanho_monitor decimal(10,1), bt_vem_com_office bool, ds_sistema_operacional varchar(100), nm_marca varchar(100), ds_processador varchar(100), ds_memoria_ram varchar(100), ds_armazenamento int ); ``` > Insert Script ```sql= Insert into tb_computador (vl_preco, ds_tamanho_monitor, bt_vem_com_office, ds_sistema_operacional, nm_marca, ds_processador, ds_memoria_ram, ds_armazenamento) Values (1756, 19.5, true, 'windows 10', 'positivo', 'intel i5 7° Geração', '4 gb de memório ram ddr3', 500), (1200, 11.6, true, 'Chrome OS', 'Samsung', 'Intel Dual Core', '4 gb de memória ram', 32), (4299, 15.6, true, 'Windows 10', 'Lenovo', 'Ryzen 7-3700U', '8 GB de ram ddr4', 580); ``` > Select Script ```sql= -- Consulta por computador que a memória ram for maior que 4 e o armazenamento interno for maior ou igual a 500. select * from tb_computador where ds_memoria_ram > 4 and ds_armazenamento >= 500; -- Consulta por computadores onde o preço for menor do que 1600 reais. select*from tb_computador where vl_preco < 1600; ```

    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