Isabela Silva Sousa
    • 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
    # Session Three: It's always time to restart | SQL autor: Isabela Silva Sousa [toc] ## Modelagem : Livraria >[color=hotpink]DER >![](https://i.imgur.com/O1umr09.png) >[color=hotpink]Create script ```sql= CREATE TABLE TB_Endereços ( ID_Endereco int primary key auto_increment, DS_CEP varchar(100), DS_Endereco varchar(100), NR_Endereco int, DS_Cidade varchar(100) ); CREATE TABLE TB_Clientes ( ID_Cliente int primary key auto_increment, NM_Cliente varchar(100), DS_CPF varchar(100), NR_Telefone_Celular varchar(100), ID_Endereco int ); CREATE TABLE TB_Venda_Item ( ID_Venda_Item int primary key auto_increment, ID_Venda int, ID_Livro int ); CREATE TABLE TB_Vendas ( ID_Venda int primary key auto_increment, ID_Cliente int, DT_Venda date, TP_Forma_Pagamento varchar(100), DS_Nota_Fiscal varchar(100), ID_Endereço int ); CREATE TABLE TB_Categorias ( ID_Categoria int primary key auto_increment, NM_Categoria varchar(100) ); CREATE TABLE TB_Livros ( ID_Livro int primary key auto_increment, ID_Categoria int, NM_Livro varchar(100), VL_Preco decimal(15,2) ); CREATE TABLE TB_Estoque ( ID_Estoque int primary key auto_increment, ID_Livro int, QTD_Minimo varchar(100), QTD_Disponivel varchar(100) ); ``` >[color=hotpink] Insert script ```sql= INSERT INTO TB_Endereços (DS_CEP, DS_Endereco, NR_Endereco, DS_Cidade) VALUES ('04842-220', 'R. Isabel Aguiar de Campos - Grajau', 360, 'São Paulo'), ('04843-210', 'Rua Yolanda Polastron - Parque São Paulo', 131, 'São Paulo'), ('04842-330', 'R. Serafim Ciuvalschi - Parque Grajau', 105, 'São Paulo - SP'), ('04842-250', 'R. Aldemar Taváres - Parque Grajau', 211, 'São Paulo - SP'), ('04743-060', 'Rua Barão de Duprat - Santo Amaro', 110, 'São Paulo - SP'), ('04809-140', 'R. Augusta Reimberg - Terceira Divisão de Interlagos', 455, 'São Paulo - SP'), ('07025-190', 'R. José Mandotti, 43 - Vila Augusta', 96, 'Guarulhos'), ('01518-020', 'Rua Leopoldo Miguez - Cambuci', 38, 'São Paulo - SP'), ('01225-030', 'R. Dr. Frederico Steidel - Campos Elíseos', 210, 'São Paulo - SP'), ('08412-000', 'R. Otelo Augusto Ribeiro - Guaianases', 59, 'São Paulo - SP'), ('18072-856', 'R. Seraphim Banietti - Caguassu', 1080, 'Sorocaba'), ('01321-001', 'R. Martiniano de Carvalho - Bela Vista', 365, 'São Paulo - SP'), ('09993-300', 'R. Carlos Drumond de Andrade - Conceição', 73, 'Diadema - SP'), ('01049-010', 'R. Quirino de Andrade - Consolação', 55, 'São Paulo - SP'), ('03315-000', 'Rua Padre Estevão Pernet - Tatuape', 615, 'São Paulo - SP'), ('05413-02', 'Rua Henrique Schaumann, 85 - Pinheiros', 105, 'São Paulo - SP'), ('02987-000', 'R. Gov. Rodrigo Henriques - Jaragua', 453, 'São Paulo - SP'), ('01225-030', 'R. Dr. Frederico Steidel - Campos Elíseos', 317, 'São Paulo - SP'), ('04842-250', 'R. Aldemar Taváres - Parque Grajau', 15, 'São Paulo - SP'), ('04843-210', 'Rua Yolanda Polastron - Parque São Paulo', 245, 'São Paulo'), ('04842-250', 'R. Aldemar Taváres - Parque Grajau', 100, 'São Paulo - SP'), ('18072-856', 'R. Seraphim Banietti - Caguassu', 65, 'Sorocaba'), ('04842-220', 'R. Isabel Aguiar de Campos - Grajau', 36, 'São Paulo'), ('09993-300', 'R. Carlos Drumond de Andrade - Conceição', 780, 'Diadema - SP'), ('04843-210', 'Rua Yolanda Polastron - Parque São Paulo', 13, 'São Paulo'); INSERT INTO TB_Clientes (NM_Cliente, DS_CPF, NR_Telefone_Celular, ID_Endereco) VALUES ('Isabelly de Souza Nascimento', '410.652.908-45', '(15)97579-5757', 11), ('Ana Luisa Partenazi Lopez', '501.459.208-28', '(11)98857-3204', 2), ('Maria Luisa Ribeiro de Souza', '890.653.167.-18', '(11)97642-2568', 3), ('Leonardo Oliveira da Silva', '567.984.124-23', '(11)95672-9526', 4), ('Bianca de Magalhães Oliveira', '678.925.027-13', '(11)96352-6272', 5), ('Matheus Paulino de Sousa', '153.764.975-97', '(11)92537-8728', 6), ('Joaquim Rodrigues Siqueira', '363.836.927-92', '(15)94363-8262', 7), ('Isabela Miranda Gonçales Mendes', '926.825.152-14', '(11)95242-6154', 8), ('João Paulo Rideki Gomes', '426.165.725-41', '(11)92314-7252', 9), ('Gustavo Henrique da Silva Soares', '436.725.872-24', '(11)97215-8232', 10), ('Leonardo Castro dos Anjos', '217.788.133-67', '(11)94252-8263', 1), ('luisa Cardoso de Oliveira Rosa', '647.143.038-01', '(11)91427-1538', 12), ('Lucas Nunes da Silva', '173.189.173-77', '(11)90731-4272', 13), ('Eduardo Cardoso Mendes', '174.926.163-71', '(11)97152-1421', 14), ('Henrique da Silva Pereira', '164.936.162-11', '(11)91527-1936', 15), ('Heloisa de Jesus Gomes', '926.262.112-20', '(11)97145-6281', 16), ('Erika Rodrigo Pires da Conceição Mendes', '721.273.721-82', '(11)91423-1523', 17), ('Cristina Aparecida Sales de Paula Paulino', '262.142.111-10', '(11)95423-9851', 18), ('Donisete da Silva Pereira', '165.122.222-12', '(11)93241-8430', 19), ('Julia da Silva Rodrigues', '970.001.162-90', '(15)92521-2215', 22), ('Guilherme Cimate Gomes', '016.165.826-06', '(11)91436-6382', 21), ('Rodrigo Gustavo de sousa Pires', '982.152.333-95', '(11)93135-9191', 20), ('Alice Ribeiro de Sousa Rodrigues', '321.213.234-03', '(11)91234-9845', 23), ('Elias Dantas Costa', '341.122.218-41', '(11)90162-1862', 24), ('Beatriz de Lurdes do Santos da Silveira', '175.912.123.34', '(11)92156-9821', 25); INSERT INTO TB_Venda_Item (ID_Venda, ID_Livro) VALUES (25, 1), (24, 2), (23, 3), (22, 4), (21, 5), (20, 6), (19, 7), (18, 8), (17, 9), (16, 10), (15, 11), (14, 12), (13, 13), (12, 14), (11, 15), (10, 16), (9, 17), (8, 18), (7, 19), (6, 20), (5, 20), (5, 19), (3, 18), (2, 17), (1, 16), (2, 15), (4, 14), (6, 13), (8, 12), (10, 11), (12, 10), (14, 9), (16, 8), (18, 7), (20, 6), (22, 5), (24, 4), (25, 8), (3, 9), (6, 10), (9, 11), (12, 12), (15, 13), (18, 14), (21, 15), (24, 16), (22, 17), (23, 18), (24, 19), (24, 20); INSERT INTO TB_Vendas (ID_Cliente, DT_Venda, TP_Forma_Pagamento, DS_Nota_Fiscal, ID_Endereço) VALUES (50, '2021-05-02', 'Dinheiro', '25389022534', 24), (25, '2020-02-15', 'Cartão', '02162782629', 1), (49, '2020-08-15', 'Dinheiro', '627202638292', 23), (24, '2021-10-12', 'Cartão', '1638263292739', 2), (48, '2020-12-27', 'Cartão', '628253926219', 22), (23, '2020-03-29', 'Cartão', '017373427826', 3), (47, '2020-08-12', 'Cartão', '615328390216', 21), (22, '2020-06-05', 'Cartão', '163549201632', 4), (46, '2020-07-22', 'Dinheiro', '538292548291', 20), (21, '2020-11-02', 'Cartão', '254729363491', 5), (45, '2021-09-13', 'Cartão', '083512817389', 19), (20, '2020-05-05', 'Cartão', '109625434829', 6), (44, '2021-05-18', 'Dinheiro', '052819153811', 18), (19, '2021-02-02', 'Dinheiro', '097152718231', 7), (43, '2020-03-02', 'Dinheiro', '273920127368', 17), (18, '2021-06-01', 'Cartão', '96252183612', 8), (42, '2021-07-01', 'Cartão', '15379624391', 16), (17, '2020-11-08', 'Dinheiro', '54901630181', 9), (41, '2020-12-09', 'Cartão', '54901634381', 15), (16, '2021-03-12', 'Cartão', '01735472822', 10), (40, '2021-10-12', 'Cartão', '82017363922', 14), (15, '2021-03-29', 'Cartão', '02836382927', 11), (39, '2021-02-02', 'Dinheiro', '027344912011', 13), (14, '2021-10-12', 'Cartão', '643820163632', 12), (28, '2020-03-29', 'Dinheiro', '15363438296', 13), (13, '2020-11-02', 'Cartão', '62437119327', 12), (37, '2020-05-02', 'Cartão', '62835382911', 14), (12, '2021-02-02', 'Cartão', '930273543721', 15), (36, '2021-06-01', 'Dinheiro', '17454028252', 11), (11, '2020-07-01', 'Cartão', '03725135229', 16), (35, '2020-11-02', 'Dinheiro', '027453272120', 17), (10, '2021-03-29', 'Cartão', '64829163920', 10), (34, '2021-08-12', 'Cartão', '63173732109', 18), (9, '2021-07-01', 'Dinheiro', '16364722907', 9), (33, '2021-05-02', 'Cartão', '18364572088', 19), (8, '2021-10-12', 'Cartão', '71937490087', 8), (32, '2020-07-01', 'Dinheiro', '6643138901', 20), (7, '2021-08-12', 'Cartão', '16353729965', 7), (31, '2020-05-02', 'Cartão', '61532628197', 21), (6, '2021-11-02', 'Dinheiro', '62537281899', 6), (30, '2020-06-01', 'Cartão', '62512436216', 22), (5, '2021-02-02', 'Dinheiro', '92638292722', 5), (29, '2020-05-02', 'Dinheiro', '7282632637826', 23), (4, '2021-08-12', 'Dinheiro', '92027372823', 4), (28, '2020-03-29', 'Dinheiro', '02735482933', 24), (3, '2021-10-12', 'Cartão', '739400735283', 3), (27, '2020-11-02', 'Cartão', '09753745854', 25), (2, '2020-07-01', 'Dinheiro', '083538283262', 2), (16, '2021-02-02', 'Cartão', '63729973078', 25), (1, '2021-09-13', 'Cartão', '726399163263', 1); INSERT INTO TB_Categorias (NM_Categoria) VALUES ('Literatura Internascional'), ('Literatura Nascional'), ('Humor e Entretenimento'), ('Teen'), ('Religião'), ('infantil'), ('Ciências Sociais'), ('Didaticos'), ('Ensino de Linguas'); INSERT INTO TB_Livros (ID_Categoria, NM_Livro, VL_Preco) VALUES (1, 'A Revolução dos Bichos', 29.90), (3, 'As aventuras de Mike 2: O bebê chegou!', 30.72), (5, 'A NOSSA ÚNICA CASA', 29.90), (7, 'PEQUENO MANUAL ANTIRRACISTA', 27.90), (9, 'imagine english 3 workbook', 10.00), (2, 'Grande Sertão: Veredas (Edição de bolso)', 37.42), (4, 'Um de nó esta mentindo', 49.90), (6, 'Malala, a menina que queria ir para a escola', 37.90), (8, 'O diário de Anne Frank', 36.42), (1, 'Esplêndida (Trilogia Damas Rebeldes – LIVRO 1)', 39.90), (5, 'MITOLOGIA DOS ORIXÁS', 84.90), (9, 'Gramatica inglesa para leigos', 86.00), (7, 'A VIDA NÃO É ÚTIL', 29.90), (4, 'Aristóteles e Dante descobrem os segredos do universo', 39.90), (3, 'Uma proposta irrecusável', 38.42), (1, 'Corte de espinhos e rosas (VOL. 1)', 54.90), (8, 'MENTIROSOS', 39.90), (6, 'O pequeno príncipe1', 11.50), (4, 'Harry Potter e a pedra filosofal', 44.90), (2, 'O Garoto quase atropelado', 10.00); INSERT INTO TB_Estoque (ID_Livro, QTD_Minimo, QTD_Disponivel) VALUES (20, 15, 15), (19, 14, 12), (18, 33, 33), (17, 24, 20), (16, 20, 20), (15, 50, 38), (14, 13, 13), (13, 35, 32), (12, 54, 50), (11, 28, 28), (10, 37, 37), (9, 13, 10), (8, 16, 16), (7, 31, 31), (6, 12, 5), (5, 42, 20), (4, 46, 38), (3, 15, 15), (2, 15, 3), (1, 29, 15); ``` >[color=hotpink] Select ```sql= SELECT * FROM TB_Endereços; SELECT * FROM TB_Clientes; SELECT * FROM TB_Venda_Item; SELECT * FROM TB_Vendas; SELECT * FROM TB_Categorias; SELECT * FROM TB_Livros; SELECT * FROM TB_Estoque; ```

    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