Bazy danych Ćwiczenia z SQL



Podobne dokumenty
Zmiany techniczne wprowadzone w wersji Comarch ERP Altum

Ilona B. Miles website Terms of Use (ewentualnie: Service)

Projektowanie baz danych Laboratorium

New Hire Form - Poland

Lista zadań nr 1. Bazy danych laboratorium. dr inż. Grzegorz Bazydło, dr inż. Jacek Tkacz

KOLEKCJE - to typy masowe,zawierające pewną liczbę jednorodnych elementów

Informatyka sem. III studia inżynierskie Transport 2018/19 LAB 2. Lab Backup bazy danych. Tworzenie kopii (backup) bazy danych

SUPPLEMENTARY INFORMATION FOR THE LEASE LIMIT APPLICATION

POLITYKA PRYWATNOŚCI / PRIVACY POLICY

Zarządzanie sieciami telekomunikacyjnymi

Instrukcja konfiguracji usługi Wirtualnej Sieci Prywatnej w systemie Mac OSX

HAPPY ANIMALS L01 HAPPY ANIMALS L03 HAPPY ANIMALS L05 HAPPY ANIMALS L07

HAPPY ANIMALS L02 HAPPY ANIMALS L04 HAPPY ANIMALS L06 HAPPY ANIMALS L08

Change Notice/ Zmienić zawiadomienie BLS Instructor Manual / Podstawowe czynności resuscytacyjne Podrecznik Instruktora

Plan. ! Podzapytania (subqueries) ! Podzapytania do tabel. ! Podzapytanie jako wyrażenie. ! Podzapytania skorelowane. ! operatory IN, NOT IN

INSTRUKCJE JAK AKTYWOWAĆ SWOJE KONTO PAYLUTION

DO MONTAŻU POTRZEBNE SĄ DWIE OSOBY! INSTALLATION REQUIRES TWO PEOPLE!

Jak otrzymać zwrot części zapłaty od X-Rite Poradnik

LEARNING AGREEMENT FOR STUDIES

THE RAIL RATES valid from 1st October 2015

OPRAWY I CZÊŒCI ZNORMALIZOWANE DO T OCZNIKÓW

Zbiór pytań nr 2. 1 Tabela DEPARTMENTS ma następującą strukturę:

U3000/U3100 Mini (Dla Komputera Eee na systemie operacyjnym Linux) Krótka Instrukcja

Ćwiczenia 2 IBM DB2 Data Studio

1 Nazwisko i imiona lub nazwa firmy będącej podmiotem uprawnionym /Surname and forenames or name of firm of applicant/

Wykaz linii kolejowych, które są wyposażone w urządzenia systemu ETCS

ACESS- zadania z wykorzystaniem poleceń SQL

Lista zadań nr Wyświetlić imię i nazwisko dla każdego pracownika z departamentu DEP T NO o numerze 000.

KOMUNIKAT 2. The 44 th International Biometrical Colloquium and IV Polish-Portuguese Workshop on Biometry. Conference information:

Raport bieżący: 44/2018 Data: g. 21:03 Skrócona nazwa emitenta: SERINUS ENERGY plc

Office 365 Midsize Business

Wykaz linii kolejowych, które są wyposażone w urzadzenia systemu ETCS

FORMULARZ APLIKACYJNY CERTYFIKACJI STANDARDU GLOBALG.A.P. CHAIN OF CUSTODY GLOBALG.A.P. CHAIN OF CUSTODY APPLICATION FORM

1: 2: 3: 4: 5: 6: 7: 8: 9: 10:

SUPPLEMENTARY INFORMATION FOR THE LEASE LIMIT APPLICATION

kdpw_stream Struktura komunikatu: Status komunikatu z danymi uzupełniającymi na potrzeby ARM (auth.ste ) Data utworzenia: r.

Podstawy języka SQL Co to jest SQL? Możliwości SQL SQL*Plus

Zapytanie o cenę: dotyczy:

OBWIESZCZENIE MINISTRA INFRASTRUKTURY. z dnia 18 kwietnia 2005 r.

PORTS AS LOGISTICS CENTERS FOR CONSTRUCTION AND OPERATION OF THE OFFSHORE WIND FARMS - CASE OF SASSNITZ

1. Właścicielem sklepu jest firma Damned Pages Distro & Promotion Paweł Dariusz Oramus z siedzibą we Wrocławiu, Polska.

ATM (Automatic Teller Machine)

Bazy Danych i Usługi Sieciowe

User s manual for icarwash

Nowe technologie baz danych

HAPPY K04 INSTRUKCJA MONTAŻU ASSEMBLY INSTRUCTIONS DO MONTAŻU POTRZEBNE SĄ DWIE OSOBY! INSTALLATION REQUIRES TWO PEOPLE! W5 W6 G1 T2 U1 U2 TZ1

Umowa Licencyjna Użytkownika Końcowego End-user licence agreement

FORMULARZ REKLAMACJI Complaint Form

15. Funkcje i procedury składowane PL/SQL


Installation of EuroCert software for qualified electronic signature

CPX Cisco Partner Excellence CSPP program partnerski

Użyj tego działania portalu dostawcy w celu wyświetlenia wszystkich szczegółowych informacji w nowym zamówieniu.

Zakopane, plan miasta: Skala ok. 1: = City map (Polish Edition)

Wybór EUROPEAN będzie rozpoznawał dzień przed miesiącem, natomiast US miesiąc przed dniem.

Key Info. Some white chocolates are taken out of the box. There are now 30 chocolates in the box. The number of white chocolates has halved.

An employer s statement on the posting of a worker to the territory of the Republic of Poland

Bazy danych i usługi sieciowe

Intro. I.Wojnicki, ZTB:XML ZTB: XML. Igor Wojnicki. Katedra Informatyki Stosowanej, Akademia Górniczo-Hutnicza w Krakowie.

Marek Rakowski Podstawy zdania SELECT Strona 1 z 12

Zasady rejestracji i instrukcja zarządzania kontem użytkownika portalu

APEX zaawansowany raport

Oferta przetargu. Poland Tender. Nazwa. Miejscowość. Warszawa Numer ogłoszenia. Data zamieszczenia Typ ogłoszenia

Revenue Maximization. Sept. 25, 2018

DO MONTAŻU POTRZEBNE SĄ DWIE OSOBY! INSTALLATION REQUIRES TWO PEOPLE!

PROMOTION - Flexible Ducts and Accessories - FLX-REKU P13.1/2013

Has the heat wave frequency or intensity changed in Poland since 1950?

Key Info. Some white chocolates are taken out of the box. There are now 30 chocolates in the box. The number of white chocolates has halved.

Laboratorium 3. Odkrywanie reguł asocjacyjnych.

Working Tax Credit Child Tax Credit Jobseeker s Allowance

Modelowanie wymiarów

Patients price acceptance SELECTED FINDINGS

Kwestionariusz samooceny dostawcy Self-rating form for suppliers

Jak otrzymać zwrot części zapłaty Poradnik

OSTC GLOBAL TRADING CHALLENGE MANUAL

3. Podzapytania, łączenie tabel i zapytań

Machine Learning for Data Science (CS4786) Lecture11. Random Projections & Canonical Correlation Analysis

Wzór zlecenia dotyczącego przeniesienia Akredytywy obcej

w PL/SQL bloki nazwane to: funkcje, procedury, pakiety, wyzwalacze

Lab.8: Podstawy języka SQL.

Aliasy Select p.first_name, p.salary, j.job_title from employees p, jobs j where p.job_id=j.job_id;

DO MONTAŻU POTRZEBNE SĄ DWIE OSOBY! INSTALLATION REQUIRES TWO PEOPLE!

Camspot 4.4 Camspot 4.5

10. Wybierz nazwy produktów oraz inf. o stanie magazynu dla produktów dostarczanych przez firmę.tokyo Traders.

ZGŁOSZENIE WSPÓLNEGO POLSKO -. PROJEKTU NA LATA: APPLICATION FOR A JOINT POLISH -... PROJECT FOR THE YEARS:.

nowy termin ważności Akredytywy / Gwarancji do / new validity term of the Letter of Credit / Guarantee:

MS Visual Studio 2005 Team Suite - Performance Tool

MaPlan Sp. z O.O. Click here if your download doesn"t start automatically

Jak otrzymać zwrot części zapłaty Poradnik

Katowice, plan miasta: Skala 1: = City map = Stadtplan (Polish Edition)

Extraclass. Football Men. Season 2009/10 - Autumn round

Lista osób, zakwalifikowanych do zakwaterowania w domach studenckich Uniwersytetu Wrocławskiego w roku akademickim 2017/2018

select zam_id, cena_euro,(rank() over (partition by zam_id order by cena_euro)) from pozycjezamowien order by zam_id

Marek Rakowski Zdanie SELECT wybieranie danych z wielu tabel Strona 1 z 6

Weronika Mysliwiec, klasa 8W, rok szkolny 2018/2019

Gdzie jest moja tabela?

****/ZN/2012. if you are pregnant or breast-feeding.

Transkrypt:

Bazy danych Ćwiczenia z SQL W ćwiczeniach wykorzystano przyk adowy schemat bazy danych dostarczany z Personal Oracle 8 Definicję schematu i dane tabel zawiera plik bdemobld sql (c) 2001 Katedra Informatyki i Automatyki PRz 1/5

Diagram związków encji pokazany ni ej modeluje schemat bazy danych firmy handlowej Gwiazdkami zaznaczono atrybuty kluczowe encji Związkom odpowiadają klucze obce o nazwach identycznych z nazwami atrybutów kluczowych Wyjątkiem jest SALESPERSON ID - referencja do atrybutu kluczowego tabeli EMPLOYEE oraz MANAGER ID - referencja do atrybutu kluczowego tabeli EMPLOYEE LOCATION LOCATION ID* REGIONAL GROUP DEPARTMENT DEPARTMENT ID* NAME JOB JOB ID* FUNCTION manager id EMPLOYEE EMPLOYEE ID* LAST NAME FIRST NAME MIDDLE INITIAL HIRE DATE SALARY COMMISSION MANAGER ID (FK) salesperson id SALES ORDER ORDER ID* ORDER DATE SHIP DATE TOTAL ITEM ITEM ID* ACTUAL PRICE QUANTITY TOTAL CUSTOMER CUSTOMER ID* NAME ADDRESS CITY STATE ZIP CODE AREA CODE PHONE NUMBER SALESPERSON ID (FK) CREDIT LIMIT COMMENTS PRODUCT PRODUCT ID* DESCRIPTION PRICE LIST PRICE* MIN PRICE START DATE END DATE Wykonać następujące ćwiczenia 1 Wyświetlić nazwiska i etaty pracowników wydzia ów ʼRESEARCHʼ lub ʼSALESʼ sortowane wed ug nazwisk i wed ug wydzia ów 2 Wyświetlić nazwiska i etaty analityków (ʼANALYSTʼ) zatrudnionych w miastach ʼNEW YORKʼ lub ʼBOSTONʼ (c) 2001 Katedra Informatyki i Automatyki PRz 2/5

3 Podać polecenie, które wyświetli na konsoli SQL następujące dane: Pracownik nazwisko pracuje na etacie etat od data zatrudnienia 4 Wyświetlić nazwisko, nazwę wydzia u i kwotę sprzeda y za poprzedni miesiąc pracowników zatrudnionych na etacie ʼSALESPERSONʼ, których sprzeda przekroczy a 1280 USD eby ustalić poprzedni miesiąc sprawdzić odpowiednim poleceniem kiedy zosta o z o one ostatnie zamówienie Nie mo na u yć EMPLOYEE SALARY poniewa atrybut ten zawiera kwotę sprzeda y w aktualnym miesiącu 5 Dla ka dego klienta wyświetlić jego nazwę i sumę w USD na jaką z o y dotychczas zamówienia Zapytanie powinno te wyświetlić klientów, którzy jeszcze nic nie kupili 6 Wyświetlić liczbę zamówień oraz średnią wartość jednego zamówienia przyjętego przez pracowników wydzia ów ʼSALESʼ (sprzeda ) w poszczególnych miastach Wynik powinien zawierać następujące informacje: Miasto, liczba przyjętych zamówień, średnia wartość zamówienia 7 Wyświetlić nazwy wszystkich klientów, daty z o enia zamówień, ilość i nazwę ka dego towaru, który zamówili Zapytanie powinno pokazać tak e klientów, którzy jeszcze nic nie kupili, zamówienia, które nie mają adnych pozycji i towary, których jeszcze nikt nie kupi Dodatkowe informacje o schemacie Tabela lub kolumna EMPLOYEE ʼGeneral information on all corporate employees ʼ; EMPLOYEE EMPLOYEE ID ʼEmployee Number: Unique 4-digit identification number assigned to every employee ʼ; EMPLOYEE LAST NAME ʼLast name of employee Stored in all caps ʼ; EMPLOYEE FIRST NAME ʼFirst name of employee Stored in all caps ʼ; EMPLOYEE MIDDLE INITIAL ʼMiddle initial (one character only) Stored in all caps ʼ; EMPLOYEE JOB ID ʼJob identification number See JOB for descriptions ʼ; EMPLOYEE MANAGER ID ʼManager: The employee number of this employeeʼʼs manager If employee has no manager, value should be NULL ʼ; EMPLOYEE HIRE DATE ʼDate the employee was HIRED, not necessarily the day the employee STARTED ʼ; EMPLOYEE SALARY ʼMonthly salary for the employee in U S dollars Salary grade information can be found in the table SALARY GRADE ʼ; EMPLOYEE COMMISSION ʼCommission (in U S dollars) earned last month This field should be NULL for non-commissioned employees ʼ; EMPLOYEE DEPARTMENT ID ʼEmployeeʼʼs department number Further department information is available in the table DEPT ʼ; JOB ʼAll valid job categories for personnel information ʼ; JOB JOB ID ʼUnique 3-digit code for job function and title ʼ; JOB FUNCTION ʼGeneric function class of job ʼ; (c) 2001 Katedra Informatyki i Automatyki PRz 3/5

Tabela lub kolumna DEPARTMENT DEPARTMENT DEPARTMENT ID DEPARTMENT NAME DEPARTMENT LOCATION ID LOCATION LOCATION LOCATION ID LOCATION REGIONAL GROUP PRODUCT ʼDepartment information for all U S operations ʼ; ʼDepartment number: Unique 2-digit department number assigned to each department ʼ; ʼDepartment name: Only the first 14 characters of a department name can be stored in the database Storing names in all caps is recommended but not required ʼ; ʼDepartment location: The code for where the departmentʼʼs central office is located (LOCATION)ʼ; ʼLocation information for all U S departments and warehouses ʼ; ʼCentral location corporate location code ʼ; ʼMetropolitan center closest to location ʼ; ʼProducts in catalog Pricing information can be found in table PRICE ʼ; PRODUCT PRODUCT ID ʼUnique 6 digit number assigned to all products Number generated by sequence PRODUCT ID ʼ; PRODUCT DESCRIPTION ʼFull product name (up to 30 characters) Storing product names in all caps is recommended but not required ʼ; PRICE ʼPrices (both standard and minimum) of products Database tracks both effective dates and expiration dates for prices ʼ; PRICE PRODUCT ID ʼProduct number to which price applies Product name found in table PRICE ʼ; PRICE LIST PRICE ʼUndiscounted price (in U S dollars) ʼ; PRICE MIN PRICE ʼLowest price (in U S dollars) that can be offered ʼ; PRICE START DATE ʼDate which standard and minimum prices go into effect ʼ; PRICE END DATE ʼDate which standard and minimum price expire This value can be left NULL ʼ; SALES ORDER ʼSales order for a customer Items in the order can be found in the table ITEM ʼ; SALES ORDER ORDER ID ʼUnique 4 digit number assigned to all orders Number generated by sequence ORDER ID ʼ; SALES ORDER ORDER DATE ʼDate sales order logged (not necessarily when order was fulfilled )ʼ; SALES ORDER CUSTOMER ID ʼCustomer ordering the goods Further information can be found in the table CUSTOMER ʼ; SALES ORDER SHIP DATE ʼDate order fulfilled and invoice sent (not necessarily date payment received) ʼ; SALES ORDER TOTAL ʼTotal of all items totals in the order (i e the value of TOTAL for order N should contain: SELECT SUM(TOTAL) FROM ITEM WHERE ORDER ID=N)ʼ; (c) 2001 Katedra Informatyki i Automatyki PRz 4/5

Tabela lub kolumna CUSTOMER CUSTOMER CUSTOMER ID CUSTOMER NAME CUSTOMER ADDRESS CUSTOMER CITY CUSTOMER STATE CUSTOMER ZIP CODE CUSTOMER AREA CODE CUSTOMER PHONE NUMBER CUSTOMER SALESPERSON ID CUSTOMER CREDIT LIMIT CUSTOMER COMMENTS ITEM ITEM ORDER ID ITEM ITEM ID ITEM PRODUCT ID ITEM ACTUAL PRICE ITEM QUANTITY ʼInformation on all U S customers and prospective customers ʼ; ʼUnique 6 digit number assigned to all customers Number generated by the sequence CUSTOMER ID ʼ; ʼFull store name of every customer (up to 45 characters) Storing names in all caps is recommended but not required ʼ; ʼStreet address of customer CITY, STATE, and ZIP CODE make up the rest of the address ʼ; ʼCity name for address of customer Storing city names in all caps is recommended, but not required ʼ; ʼTwo letter abbreviation for state name for address of customer Must be entered in all caps ʼ; ʼZip code of customer Supports both 5 and 9 digit zip codes Dashes should be omitted from 9 digit zips ʼ; ʼArea code of phone number for customer ʼ; ʼPhone number of customer This field does not supports letters and spaces for mnemonics (7 numeric digits only) ʼ; ʼEmployee number of sales representative handling customerʼʼs account Employee information can be found in the EMPLOYEE table ʼ; ʼCredit limit of customer or prospective customer in U S dollars ʼ; ʼField can be used flexibly Suggestions for use include lists of action items or special considerations when dealing with the particular customer ʼ; ʼItems listed in sales orders Product information can be found in table PRODUCT Sales order information can be found in table SALES ORDER ʼ; ʼSales order in which this item appears Sales order information can be found in table SALES ORDER ʼ; ʼNumber of item within the sales order ʼ; ʼNumber of product (described in PRODUCT) that pertains to the line item ʼ; ʼPrice to be paid by the customer in U S dollars The standard price is PRICE STANDARD PRICE, but in some instances, discounts are given to as low as PRICE MINIMUM PRICE ʼ; ʼThe amount of product to be ordered in this line item ʼ; ITEM TOTAL ʼThe total price (in U S dollars) of this line item TOTAL = ACTUAL PRICE * QUANTITY ʼ; (c) 2001 Katedra Informatyki i Automatyki PRz 5/5