Elias de Freitas Cavalcante
    • 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
    # Final session Banco de Dados **Autor**:Elias de Freitas Cavalcante **Número**:12 **Turma**: INFO C [TOC] ## 1.Modelagem Catálogo Google Play > Create script ```sql= CREATE TABLE tb_apps( id int primary key auto_increment, nm_nome varchar(255), ds_genero varchar(255), bt_appstore bool, bt_googleplay bool, nm_totaldownload varchar(200), nr_avaliacao decimal(10,1), nm_criador varchar(255), ds_tamanho varchar(255), ds_ultimaatualizacao varchar(255) ); ``` > Insert script ```sql= INSERT INTO tb_apps( nm_nome, ds_genero, bt_appstore, bt_googleplay, nm_totaldownload, nr_avaliacao, nm_criador, ds_tamanho, ds_ultimaatualizacao) VALUES( 'Tik Tok', 'Dance-pop electropop', true, true, '2 Bilhões', 2.7, 'Zhang Yiming', '88,00 MB (Android) 405,7 MB (iOS)', '18.9.4'); INSERT INTO tb_apps( nm_nome, ds_genero, bt_appstore, bt_googleplay, nm_totaldownload, nr_avaliacao, nm_criador, ds_tamanho, ds_ultimaatualizacao) VALUES( 'Instagram', 'Publicações de Fotos e Vídeos', true, true, '238 milhões', 4.8, 'Kevin Systrom', '159,7 MB', '183.0'); INSERT INTO tb_apps( nm_nome, ds_genero, bt_appstore, bt_googleplay, nm_totaldownload, nr_avaliacao, nm_criador, ds_tamanho, ds_ultimaatualizacao) VALUES( 'Clash Royale', 'Multiplayer online battle arena, RPG, eletrônico de ação', false, true, '100 milhões',4.7, 'Supercell', '169,5 MB', '3.5.0'); ``` > Select script ```sql= -- Consulta os apps que estão disponiveis na appstore e ordenando a avaliação em ordem crecente. SELECT*FROM tb_apps WHERE bt_appstore ='1' ORDER BY nr_avaliacao ASC; --Consulta os apps que possuem a avaliação menor que 4.8 em ordem decrecente. SELECT*FROM tb_apps WHERE nr_avaliacao < 4.8 ORDER BY nr_avaliacao DESC; --Consulta os apps que começam com as letras I e C e ordenando a avaliação em ordem decrecente. SELECT*FROM tb_apps WHERE nm_nome LIKE 'I%' OR nm_nome LIKE 'C%' ORDER BY nr_avaliacao DESC; ``` ## 2.Modelagem paises > Create script ```sql= CREATE TABLE tb_paises( id int primary key auto_increment, nm_nome varchar(255), ds_sigla varchar(255), nr_populacao varchar(255), ds_area varchar(255), ds_idioma varchar(255), nm_capital varchar(255), nm_continente varchar(255), ds_pib varchar(255), dt_aniversario date ); ``` > Insert script ```sql= INSERT INTO tb_paises( nm_nome, ds_sigla, nr_populacao, ds_area, ds_idioma, nm_capital, nm_continente, ds_pib, dt_aniversario) VALUES( 'Noruega', 'NO', '5,328 milhões','385.207 km²', 'Norueguês', 'Oslo', 'Europa', '403,3 bilhões USD', '1814-05-17'); INSERT INTO tb_paises( nm_nome, ds_sigla, nr_populacao, ds_area, ds_idioma, nm_capital, nm_continente, ds_pib, dt_aniversario) VALUES( 'Inglaterra', 'IN', '55,98 milhões', '130.279 km²', 'Inglês', 'Londres', 'Europa', '2,744 trilhões USD', '1926-04-21'); INSERT INTO tb_paises( nm_nome, ds_sigla, nr_populacao, ds_area, ds_idioma, nm_capital, nm_continente, ds_pib, dt_aniversario) VALUES( 'Brasil', 'BRA', '212 milhões', '8.516.000 km²', 'Português', 'Brasília', 'Americano', '1,84 trilhão USD', '1500-04-22'); ``` > Select script ```sql= -- Consulta todos os paises que pertencem ao continente Europeo e ordenando a data de aniversário em ordem crecente. SELECT*FROM tb_paises WHERE nm_continente = 'Europa' ORDER BY dt_aniversario ASC; -- Consulta todos os paises que a sigla começa com as letras B e N e ordenando os nomes em ordem crecente. SELECT*FROM tb_paises WHERE ds_sigla LIKE 'N%' OR ds_sigla LIKE 'B%' ORDER BY nm_nome ASC; -- Consulta todos os paises que a capital começa com as letra L e B em ordem decrecente. SELECT*FROM tb_paises WHERE nm_capital LIKE 'L%' OR nm_capital LIKE 'B%' ORDER BY nm_capital DESC; ``` ## 3.Modelagem Clube Futebol > Create script ```sql= CREATE TABLE tb_clube( id int primary key auto_increment, nm_nome varchar(255), ds_sigla varchar(255), nm_pais varchar(255), nm_cidade varchar(255), nm_estadio varchar(255), nr_capacidade decimal(10,3), nm_presidente varchar(255), nr_titulos int, dt_fundacao date ); ``` > Insert script ```sql= INSERT INTO tb_clube( nm_nome, ds_sigla, nm_pais, nm_cidade, nm_estadio, nr_capacidade, nm_presidente, nr_titulos, dt_fundacao) VALUES( 'Futbol Club Barcelona', 'FCB', 'Espanha', 'Barcelona', 'Camp Nou', 99.354, 'Joan Laporta', 91, '1899-11-29'); INSERT INTO tb_clube( nm_nome, ds_sigla, nm_pais, nm_cidade, nm_estadio, nr_capacidade, nm_presidente, nr_titulos, dt_fundacao) VALUES( 'Manchester City Football Club', 'FC St', 'Inglaterra', 'Machester', 'Etihad Stadium', 55.097, 'Khaldoon Al Mubarak', 26, '1894-04-16'); INSERT INTO tb_clube( nm_nome, ds_sigla, nm_pais, nm_cidade, nm_estadio, nr_capacidade, nm_presidente, nr_titulos, dt_fundacao) VALUES( 'Real Madrid Club de Fútbol', 'RMA', 'Espanha', 'Real Madrid', 'Santiago Bernabéu', 81.044, 'Florentino Pérez Rodríguez', 92, '1902-03-06'); ``` > Select script ```sql= -- Consulta os clubes que tem o estadio com a capacidade maior que 56.000 ordenando em ordem crecente. SELECT*FROM tb_clube WHERE nr_capacidade > 56.000 ORDER BY nr_capacidade ASC; -- Consulta os clubes que a sigla termina com B e A e ordenando a data de fundação em ordem decrecente. SELECT*FROM tb_clube WHERE ds_sigla LIKE '%B' OR ds_sigla LIKE '%A' ORDER BY dt_fundacao DESC; -- Consulta os clubes que são da Espanha e ordenando a capacidade em ordem crecente. SELECT*FROM tb_clube WHERE nm_pais = 'Espanha' ORDER BY nr_capacidade ASC; ``` ## 4.Modelagem Música > Create script ```sql= CREATE TABLE tb_musica( id int primary key auto_increment, nm_nome varchar(200), nm_artista varchar(255), ds_album varchar(255), ds_genero varchar(255), hr_duracao varchar(255), nr_likes int, nr_views int, dt_lancamento date ); ``` > Insert script ```sql= INSERT INTO tb_musica (nm_nome, nm_artista, ds_album, ds_genero, hr_duracao, nr_likes, nr_views, dt_lancamento) VALUES( 'M4-Gritando meu Nome', 'Teto', 'Funk Remix', 'Trap', '2:50', 1000000000, 53439576 ,'2021-01-26'); INSERT INTO tb_musica (nm_nome, nm_artista, ds_album, ds_genero, hr_duracao, nr_likes, nr_views, dt_lancamento) VALUES('Será', 'Renato Russo', 'Legião Urbana','Rock', '2:31', 42000, 3875043 , '1985-05-26'); INSERT INTO tb_musica (nm_nome, nm_artista, ds_album, ds_genero, hr_duracao, nr_likes, nr_views, dt_lancamento) VALUES('Índios','Renato Russo', 'Dois', 'Rock', '4:57', 328000, 58938512, '1986-12-12'); ``` > Select script ```sql= -- Consulta todas as musicas em que o artista é Renato Russo e ordenando os likes em ordem crecente. SELECT*FROM tb_musica WHERE nm_artista = 'Renato Russo' ORDER BY nr_likes ASC; -- Consula todas as musicas que começam com as letra M e S e ordenando as views em ordem decrecente. SELECT*FROM tb_musica WHERE nm_nome LIKE 'M%' OR nm_nome LIKE 'S%' ORDER BY nr_views DESC; -- Consulta todas as musicas em que o genero é Rock e ordenando as datas em ordem crecente. SELECT*FROM tb_musica WHERE ds_genero = 'Rock' ORDER BY dt_lancamento ASC; ``` ## 5.Modelagem Concessionária > Create script ```sql= CREATE TABLE tb_carro( id int primary key auto_increment, nm_modelo varchar(255), nm_marca varchar(255), dt_anofabricação date, dt_anomodelo date, tp_cor varchar(255), vl_preco decimal(10,3), nr_kiloetragem decimal(10), bt_arcondicionado bool, bt_direcaohidraulica bool ); ``` > Insert script ```sql= INSERT INTO tb_carro(nm_modelo,nm_marca,dt_anofabricação,dt_anomodelo,tp_cor,vl_preco,nr_kiloetragem, bt_arcondicionado, bt_direcaohidraulica) values( 'Mercedes C-63 AMG','Mercedes-Benz','2010-01-01','2008-01-01',"Preto",116.900,72000, true,true); INSERT INTO tb_carro( nm_modelo, nm_marca, dt_anofabricação, dt_anomodelo, tp_cor, vl_preco, nr_kiloetragem, bt_arcondicionado, bt_direcaohidraulica) VALUES( 'Corolla xli','Toyata','2008-02-01','2005-01-01','cinza',28.900,100000, true, true); INSERT INTO tb_carro(nm_modelo, nm_marca, dt_anofabricação, dt_anomodelo, tp_cor,vl_preco,nr_kiloetragem, bt_arcondicionado, bt_direcaohidraulica) VALUES( 'corsa Hal','Chevrolet','2009-01-01','2004-01-01','Preto',6.500,10700,true, false); ``` > Select script ```sql= --Consulta todos os carros que possuem direção Hidraulica e ordenando os preços em ordem crecente. SELECT*FROM tb_carro WHERE bt_direcaohidraulica = '1' ORDER BY vl_preco ASC; --Consulta todos os carros que pertencem a marca toyota e que possuem arcondicionado. SELECT*FROM tb_carro WHERE nm_marca = "Toyota" AND bt_arcondicionado = '1'; --Consulta os carros que o modelo começa com a letra C e ordena a kilometragem em ordem decrecente. SELECT*FROM tb_carro WHERE nm_modelo LIKE 'C%' ORDER BY nr_kiloetragem DESC; ``` ## 6.Modelagem Computador > Create script ```sql= CREATE TABLE tb_computador( id int primary key auto_increment, nm_marca varchar(255), ds_processador varchar(255), ds_memoriaram varchar(255), ds_armazenamento varchar(255), vl_preco varchar(255), ds_tamanho varchar(255), bt_office bool, bt_sistemaoperacional bool ); ``` > Insert script ```sql= INSERT INTO tb_computador( nm_marca, ds_processador, ds_memoriaram , ds_armazenamento, vl_preco, ds_tamanho, bt_office, bt_sistemaoperacional) VALUES ( 'Dell', 'Intel® Celeron G4930', '8GB', 'SSD', 'R$3.999,00', 'chassi: 360 mm (14,17 pol.) Largura do chassi: 175 mm (6,89 pol.)', true, true); INSERT INTO tb_computador( nm_marca, ds_processador, ds_memoriaram , ds_armazenamento, vl_preco, ds_tamanho, bt_office, bt_sistemaoperacional) VALUES ( 'Acer', 'Intel Core i5 7400', '8GB','HD', 'R$4.999,00', '53 x 50 x 26 cm 10.8 Quilogramas', false, true); INSERT INTO tb_computador( nm_marca, ds_processador, ds_memoriaram , ds_armazenamento, vl_preco, ds_tamanho, bt_office, bt_sistemaoperacional) VALUES ( 'HP Desktop', 'Ryzen™ 3 PRO', '4GB', 'HD', 'R$2.161,08', 'L x P x A: 13,6 x 26,18 x 31 cm', true, true); ``` > Select script ```sql= -- Consulta os computadores que possuem Office ordenando em ordem crecente. SELECT*FROM tb_computador WHERE bt_office = '1' ORDER BY bt_office ASC; -- Consulta os computadores que a MemoriaRAM é 8GB e ordena os nomes das marcas em ordem decrecente. SELECT*FROM tb_computador WHERE ds_memoriaram = '8GB' ORDER BY nm_marca DESC; -- Consulta os computdores que o Armazenamento é HD e ordena os Preços em ordem crecente. SELECT*FROM tb_computador WHERE ds_armazenamento = 'HD' ORDER BY vl_preco ASC; ```

    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