vitomtolindo
    • 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**: Vitório Trindade Santana **Turma**: Informática C **Número**: 50 [toc] ## Modelagem 1: Catálogo Loja Apps > Create Script ```sql= CREATE TABLE TB_Apps ( ID_Apps int primary key auto_increment, NM_Nome varchar (40), DS_Genero varchar (30), BT_Disponivel_App_store bool, BT_Disponivel_Google_Play bool, DT_Ultima_Atualizacao date, QTD_Tamanho decimal (4, 2), NM_Criador varchar (30), VL_Avaliacao decimal (2, 1), QTD_Total_Downloads int ); ``` > Insert Script ```sql= INSERT INTO TB_Apps (NM_Nome, DS_Genero, BT_Disponivel_App_store, BT_Disponivel_Google_Play, DT_Ultima_Atualizacao, QTD_Tamanho, NM_Criador, VL_Avaliacao, QTD_Total_Downloads) values ('Discord', 'Comunicação', true, true, '2021-04-01', 67.04, 'Discord Inc.', 4.5, 100000000), ('Netflix', 'Entreterimento', true, true, '2021-04-07', 18.37, 'Netflix, Inc.', 4.4, 1000000000), ('Instagram', 'Social', true, true, '2021-04-12', 35.81, 'Instagram', 4.4, 1000000000); ``` > Select Script ```sql= -- Consulta por aplicativos com mais de 30mb e uma avaliação maior que 4 SELECT NM_Nome, DS_Genero FROM TB_Apps WHERE QTD_Tamanho > 30 AND VL_Avaliacao > 4; -- Consulta por aplicativos que tenham um total de downloads maior ou igual que um bilhão ou que o gênero seja comunicação SELECT NM_Nome, QTD_Total_Downloads FROM TB_Apps WHERE QTD_Total_Downloads >= 1000000000 OR DS_Genero IN ('Comunicação'); ``` ## Modelagem 2: Países > Create script ```sql= CREATE TABLE TB_Paises ( ID_Paises int primary key auto_increment, NM_Nome varchar (30), NM_Sigla varchar (10), QTD_Populacao int, QTD_Area int, DT_Data_Aniversario date, VL_Pib decimal (15, 2), NM_Continente varchar (20), NM_Capital varchar (20), DS_Idioma varchar (20) ); ``` > Insert script ```sql= INSERT INTO TB_Paises (NM_Nome, NM_Sigla, QTD_Populacao, QTD_Area, DT_Data_Aniversario, VL_Pib, NM_Continente, NM_Capital, DS_Idioma) values ('Peru', 'PE', 32510000, 1285000, '2021-07-28', 1270000000, 'América', 'Lima', 'Castelhano'), ('Brasil', 'BR', 212000000, 851600, '2021-09-07', 7400000000 , 'América', 'Brasília', 'Português Brasileiro'), ('Nova Zelândia', 'NZ', 4917000, 268.021, '2021-09-26', 1158640000, 'Oceania', 'Wellington', 'Inglês'); ``` > Select script ```sql= -- Consulta por países que tenham a data de aniversário entre junho e julho e que tenham uma população maior que 30 milhões de habitantes. SELECT * FROM TB_Paises WHERE DT_Data_Aniversario between '2021-06-01' and '2021-07-30' AND QTD_Populacao > 30000000; -- Consulta por países que tenham uma populacação maior que 20 milhões de habitantes e que são da América. SELECT * FROM TB_Paises WHERE QTD_Populacao > 20000000 AND NM_Continente IN ('América'); ``` ## Modelagem 3: Clube Futebol > Create script ```sql= CREATE TABLE TB_Clube_de_Futebol ( ID_Clube_de_Futebol int primary key auto_increment, NM_Nome varchar(50), NM_Sigla varchar(10), NM_Pais varchar(40), NM_Cidade varchar(40), DT_Data_Fundacao date, QTD_Total_Titulos int, NM_Presidente varchar(70), QTD_Capacidade_Estadio int, NM_Estadio varchar(100) ); ``` > Insert script ```sql= INSERT INTO TB_Clube_de_Futebol (NM_Nome, NM_Sigla, NM_Pais, NM_Cidade, DT_Data_Fundacao, QTD_Total_Titulos, NM_Presidente, QTD_Capacidade_Estadio, NM_Estadio) values ('Sao Paulo Futebol Clube','SPFC','Brasil','São Paulo','1930-01-25',41,'Julio Casares', 66795, 'Morumbi'), ('LIverpool', 'L.F.C','inglaterra','Liverpool', '1892-06-03', 63 ,'Peter Moore', 53594, 'Anfield'), ('Paris Saint-Germain', 'PSG', 'França', 'Paris', '1970-08-12', 44, 'Nasser Al-Khelaif', 48583, 'Parc de Princes'); ``` > Select script ```sql= -- Consultar os clubes de futebol que tenham mais que 30 títulos e que o nome do país comece com "F". SELECT NM_nome ,NM_Pais FROM TB_Clube_de_Futebol WHERE QTD_Total_titulos > 30 AND NM_Pais like 'F%'; -- Consultar os clubes de futebol que tenham mais que 50 titulos ou que a capacidade do estádio seja maior que 50 mil. SELECT * FROM TB_Clube_de_Futebol WHERE QTD_Total_Titulos > 50 OR QTD_Capacidade_Estadio > 50000; ``` ## Modelagem 4: Música > Create script ```sql= CREATE TABLE TB_Musica ( ID_Musica int primary key auto_increment, NM_Nome varchar (20), NM_Artista varchar (15), NM_Album varchar (20), DS_Genero varchar (20), DT_Data_Lancamento date, QTD_Total_Views int, QTD_Duracao varchar (10) ); ``` > Insert script ```sql= INSERT INTO TB_Musica (NM_Nome, NM_Artista, NM_Album, DS_Genero, DT_Data_Lancamento, QTD_Total_Views, QTD_Duracao) values ('Ballbreaker', 'AC/DC', 'Ballbreaker', 'Hard rock', '1995-09-26', 1627638, '4:31'), ('Tusk', 'Fleetwood Mac', 'Tusk', 'Pop rock', '1979-10-12', 6409042, '3:18'), ('Sorairo Days', 'Shoko Nakagawa', 'Big Bang!!!', 'Pop japonês', '2014-04-30', 3472287, '4:12'); ``` > Select script ```sql= -- Consultar músicas que tenham o gênero rock e que a data de lançamento esteja entre 01/01/1975 e 01/01/2000. SELECT * FROM TB_Musica WHERE DS_Genero like '%rock%' AND DT_Data_Lancamento BETWEEN '1975-01-01' AND '2000-01-01'; -- Consultar músicas que tenham mais de um milhão de views e que tenham 4 minutos. SELECT NM_Nome, QTD_Total_Views, QTD_Duracao FROM TB_Musica WHERE QTD_Total_Views > 1000000 AND QTD_Duracao like '%4:%'; ``` ## Modelagem 5: Concessionária > Create script ```sql= CREATE TABLE TB_Concessionaria ( ID_Concessionaria int primary key auto_increment, NM_Modelo varchar (20), NM_Marca varchar (20), DT_Ano_Fabricacao date, DT_Ano_Modelo date, BT_Possui_Direcao_Hidraulica bool, BT_Possui_Ar_Condicionado bool, QTD_Kilometragem int, VL_Preco decimal (10, 2), DS_Cor varchar (20) ); ``` > Insert script ```sql= INSERT INTO TB_Concessionaria (NM_Modelo, NM_Marca, DT_Ano_Fabricacao, DT_Ano_Modelo, BT_Possui_Direcao_Hidraulica, BT_Possui_Ar_Condicionado, QTD_Kilometragem, VL_Preco, DS_Cor) values ('Corsa wind', 'Chevrolet', '1994-03-25', '1995-03-25', false, false, 356670, 3576.90, 'Preto'), ('Punto ELX', 'Fiat', '2010-02-27', '2010-04-15', true, false, 120430, 19570.90, 'Branco/Preto'), ('Civic', 'Honda', '2002-01-12', '2002-03-15', false, false, 234970, 12790, 'Preto'); ``` > Select script ```sql= -- Consultar um carro que tenha direção hidráulica e tenha um preço menor que 25 mil. SELECT * FROM TB_Concessionaria WHERE BT_Possui_Direcao_Hidraulica IS true AND VL_Preco < 25000; -- Consultar um carro que tenha uma kilometragem menor que 250 mil km ou que tenha um preço menor que 15 mil. SELECT NM_Modelo, NM_Marca, QTD_Kilometragem FROM TB_Concessionaria WHERE QTD_Kilometragem < 250000 OR VL_Preco < 15000; ``` ## Modelagem 6: Computador > Create script ```sql= CREATE TABLE TB_Computador ( ID_Computador int primary key auto_increment, NM_Marca varchar (20), NM_Processador varchar (20), QTD_Memoria_Ram int, QTD_Armazenamento int, NM_Sistema_Operacional varchar (30), BT_Vem_com_Office bool, QTD_Tamanho decimal (3,1), VL_Preco decimal (10,2) ); ``` > Insert script ```sql= INSERT INTO TB_Computador (NM_Marca, NM_Processador, QTD_Memoria_Ram, QTD_Armazenamento, NM_Sistema_Operacional, BT_Vem_Com_Office, QTD_Tamanho, VL_Preco) values ('Lenovo', 'Ryzen 5 3600', 12, 240, 'Windows 10 Pro', true, 16.5, 3400), ('Asus', 'Intel Core i5 9400f', 16, 500, 'Windows 7', true, 17, 2800), ('Acer', 'Ryzen 5 2500u', 8, 1000, 'Windows 10 Home', true, 15, 2400); ``` > Select script ```sql= -- Consultar um computador que venha com Office e tenha um preço menor que 3 mil. SELECT * FROM TB_Computador WHERE BT_Vem_com_Office IS true AND VL_Preco < 3000; -- Consultar um computador que tenha um armazenamento maior ou igual que 500gb, um tamanho maior que 16 e mais que 12gb de ram . SELECT * FROM TB_Computador WHERE QTD_Armazenamento > 500 AND QTD_Tamanho > 16 AND QTD_Memoria_Ram > 12; ```

    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