SlideShare ist ein Scribd-Unternehmen logo
1 von 41
Downloaden Sie, um offline zu lesen
Glenn Haertlein
                    SQL Server Portfolio




Phone: 864-385-8606
Email: glenn.haertlein@setfocus.com
http://www.linkedin.com/in/htack210

                                           1
Table of Contents
  Introduction                             3
  What is Set Focus?                       4
  JungleBooks                              5
      Database Diagram                     6
      Single Table Query                   7
  Library                                  8
      Query with Concatenation             9
      Advanced Query with Joins            10
      Query with Outer Join                11
      Join/Union Query                     12
      Alternate to Previous Query          14
      Query Using Temporary Table          16
      Query Using Aggregate Function SUM   17
      Query with Calculated Column         18
  Create View                              19
  Stored Procedure                         20

                                                2
ToC (cont’d)
Piggy Bank                                22
   Database Diagram                       23
   Stored Proc Example (Make a deposit)   24
   DDL Example                            25
About Me                                  21




                                               3
Introduction
•This portfolio contains examples of my development skills in MS SQL
Server. It is a work in progress and reflects my current work thus far in the
SetFocus Master’s Program.
•SetFocus utilizes Microsoft Official Curriculum in conjunction with its own
materials to produce some of the following coursework:
    • RDBMS and XML
    •Querying using Transact SQL
    •Implementing and maintaining a MS SQL Server 2005 Database
    •Designing an MS SQL Server 2005 Infrastructure
    •Designing security for MS SQL Server 2005
    •Designing High Availability Database Solutions using MS SQL Server 2005
    •Troubleshooting and Optimizing Database Servers using MS SQL Server 2005
    •SQL Server Integration Services
    •SQL Server Reporting Services

•In addition to the coursework and programming labs, the program includes
challenging real-world projects where I apply the skills learned in class.


                                        Return to TOC                           4
What is SetFocus?
• The SetFocus SQL Master’s Program is an intensive,
  hands-on, project-oriented program allowing
  knowledge and valuable experience putting the SQL
  skill set to use in a simulated work environment.
• I am currently enrolled and will receive over 300 hours
  of in-depth, hands-on experience focused on SQL.
• SetFocus projects are real world projects that are
  distributed just as I would receive in a position. I
  receive project specifications and am expected to
  identify best courses of action with deadlines set for
  completion.

                         Return to TOC                      5
Junglebooks Scenario
• Junglebooks is a book company which has a database consisting of books,
  authors, orders and customers.
• For this project I created a database and submitted a database diagram.
• In this project scenario, I am working with a fictitious application
  programmer who is building a client application using .NET.
• To meet the needs of the application programmer, I created queries for
  different forms of the application.




                                 Return to TOC                              6
Database Diagram




      Return to TOC   7
Single Table Query
The Cheap Books form displays available books below a
certain price. The user enters 15 in the txtUnitPrice form
field. Return ISBN, title and publisher in order by title.
       USE JungleBooks;

       DECLARE @txtUnitPrice as int = 15;

       SELECT ISBN, Title, Publisher
       FROM JungleBooks.dbo.Books as Books
       WHERE Books.UnitPrice <= @txtUnitPrice
       ORDER BY Books.Title;



                          Return to TOC                      8
Library Database Scenario
The Library Database is created to support the principal functions of a lending
library’s day-to-day operations.

For this database project, I created queries against the Library database that
returned a number of results using:
• string concatenations
• different types of joins
• UNION statements
• CASE statements
• date manipulation
• and aggregate functions.




                                    Return to TOC                                 9
Query with String Concatenation
Write and execute a query on the Member and Adult tables in the Library database that
returns the firstname, middleinitial, lastname, street, city, state and zip. Concatenate the
firstname, middleinitial and lastname columns into one string and alias as Name. Make sure
that the spacing is appropriate when there is no middle initial due to a NULL or empty string
value. Display records in order by lastname and firstname.
                USE library;

                SELECT M.firstname + ' ' +
                          CASE
                            WHEN M.middleinitial IS NULL THEN ' '
                             ELSE M.middleinitial + ' '
                           END
                           + M.lastname As Name
                         , A.street as [Street]
                         , A.city as [City]
                         , A.state as [State]
                         , A.zip as [Zip]
                FROM member as M
                         JOIN adult as A
                           ON M.member_no = A.member_no
                ORDER BY M.lastname, M.firstname;


                                         Return to TOC                                  10
Advanced Query Using Joins
Write and execute a query on the Title, Item and Copy tables that returns the ISBN, copy_no,
on_loan, title, translation, cover for rows in the copy table with an ISBN of 500 or 1000.
Only available books should be displayed and hardback copies should be listed first.

                    USE library;
                    SELECT I.isbn
                             , C.copy_no
                             , C.on_loan
                             , T.title
                             , I.translation
                             , I.cover
                    FROM item as I
                             JOIN copy as C
                               ON I.isbn = C.isbn
                             JOIN title as T
                               ON C.title_no = T.title_no
                    WHERE (C.on_loan = 'N' AND C.isbn = 500)
                             or (C.on_loan = 'N' AND C.isbn =
                    1000)
                    ORDER BY I.cover;


                                         Return to TOC                                 11
Query with Outer Join
Write and execute a query to retrieve the member’s full name and member_no from the Member table
and the ISBN and log_date values from the Reservation table for member numbers 250, 341, and 1675.
Order the results by member_no and log_date. You should show information for these members, even
if they have no books on reserve.
                  USE library;
                  SELECT M.member_no
                           , M.firstname + ' ' +
                             CASE
                                    WHEN M.middleinitial IS NULL THEN
                  ' '
                                    ELSE M.middleinitial + ' '
                             END
                           + M.lastname as Name
                           , R.isbn
                           , CAST(R.log_date as DATE) as log_date
                  FROM member as M
                           LEFT OUTER JOIN reservation as R
                             ON M.member_no = R.member_no
                  WHERE m.member_no IN (250, 341, 1675)
                  ORDER BY m.member_no, r.log_date;


                                            Return to TOC                                    12
USE library;
                                SELECT I.isbn

Join/Union Query                             ,T.title
                                             ,A.member_no
                                             ,M.lastname + ', ' +
                                             M.firstname + ' ' +
 Write and execute a query to                CASE
                                                          WHEN M.middleinitial IS NULL THEN ' '
 retrieve the member’s full                               ELSE M.middleinitial + ' '
                                             END as FullName,
 name and member_no from                     'Adult' as [Status]
 the Member table and the       FROM adult as A
                                             JOIN member as M
 ISBN and log_date values                      ON A.member_no = M.member_no
 from the Reservation table                  JOIN reservation as R
                                               ON R.member_no = A.member_no
 for member numbers 250,                     JOIN item as I
                                               ON I.isbn = R.isbn
 341, and 1675. Order the                    JOIN title as T
 results by member_no and                      ON T.title_no = I.title_no
                                WHER         E I.isbn = '288'
 log_date. You should show      UNION ALL
 information for these
                                SELECT I.isbn
 members, even if they have                  ,T.title
                                             ,J.member_no
 no books on reserve.                       ,M.lastname + ', ' +
                                            M.firstname + ' ' +
                                            CASE
                                                        WHEN M.middleinitial IS NULL THEN ' '
                                                        ELSE M.middleinitial + ' '
                                            END as FullName,
                                            'Juvenile' as [Status]
                                FROM Juvenile as J
                                            JOIN member as M
                                              ON J.member_no = M.member_no
                                                        JOIN reservation as R
                                              ON R.member_no = J.member_no
                                            JOIN item as I
                                              ON I.isbn = R.isbn
                                            JOIN title as T
                                              ON T.title_no = I.title_no
              Return to TOC                                                                       13
                                WHERE I.isbn = '288'
Query Proof




   Return to TOC   14
Alternate to Previous Query
                                USE library;
                                SELECT DISTINCT I.isbn
                                             ,T.title
                                             ,M.member_no
Write the above statement                    ,M.lastname + ', ' +
                                             M.firstname + ' ' +
again using a CASE statement.                CASE
You cannot JOIN to the Adult                              WHEN M.middleinitial IS NULL THEN ' '
                                                          ELSE M.middleinitial + ' '
or Juvenile tables. Compare                  END as FullName,
the two versions and                         [Status] =
                                               CASE
determine which one is more                      WHEN EXISTS (SELECT * FROM dbo.adult
                                                          WHERE dbo.adult.member_no=m.member_no) THEN 'Adult'
efficient. Cut and paste the                               ELSE 'Juvenile'
proof of your research. (No                     END
                                FROM
need to copy the output of                   member as M
records)                                     JOIN reservation as R
                                               ON R.member_no = M.member_no
                                             JOIN item as I
                                               ON I.isbn = R.isbn
                                             JOIN title as T
                                               ON T.title_no = I.title_no
                                WHERE R.isbn = '288'
                                ORDER BY FullName




                                               Return to TOC                                             15
Query Proof




   Return to TOC   16
Query Using Temporary Table to Store Records
  Write and execute a query that returns the member_no, full name, out_date, due_date, and
  title columns from the Loan, Member, and Title tables. Convert the datetime values from
  the out_date and due_date columns to char(12), format 101. Restrict the results to books
  which were due prior to the current date. Load the records into a temporary table called
  #overdue. Leave the query window open after you create the temporary table.
                USE library;
                IF OBJECT_ID('tempdb.dbo.#overdue') IS NOT NULL
                          DROP TABLE dbo.#overdue;
                GO
                SELECT M.member_no
                          , M.firstname + ' ' +
                          CASE
                                    WHEN M.middleinitial IS NULL THEN ' '
                                    ELSE M.middleinitial + ' '
                          END + ' ' +
                           M.lastname as FullName
                          , CONVERT(char(12), L.out_date, 101) as [Out Date]
                          , CONVERT(char(12), L.due_date, 101) as [Due Date]
                          , T.title
                INTO dbo.#overdue
                FROM loan as L
                          JOIN member as M
                            ON L.member_no = M.member_no
                          JOIN title as T
                            ON T.title_no = L.title_no
                WHERE due_date < CURRENT_TIMESTAMP
Return to TOC   ORDER BY FullName;                                                   17
Query Using Aggregate Function SUM
Write and execute a query that returns member_no, firstname, lastname and sum of
fine_paid for members who have paid the highest fines to date. Members should only
appear once in the list. Display the highest fine first. If more than one member has paid the
same amount display the records in order by member_no.
                USE library;
                SELECT M.member_no
                       , M.firstname
                       , M.Lastname
                       , CAST(SUM(LH.fine_paid) as
                Numeric(5,2)) as FinePaid
                FROM member as M
                       JOIN loanhist as LH
                         ON M.member_no = LH.member_no
                GROUP BY M.member_no, M.firstname,
                M.lastname
                HAVING SUM(LH.fine_paid) IS NOT NULL
                ORDER BY
                       FinePaid DESC,
                       M.member_no;
                                         Return to TOC                                  18
Query with Calculated Column
Write and execute a query on the Reservation table that returns the ISBN, title and Total.
The Total column is a calculated column which represents the number of members wishing
to reserve a particular book.

                  USE library;
                  SELECT R.isbn
                        ,(SELECT T.title
                               FROM title as T
                               WHERE I.title_no =
                  T.title_no) as Title
                        , COUNT(R.member_no) as
                  Total
                  FROM reservation as R
                        JOIN item as I
                          ON I.isbn = R.isbn
                  GROUP BY R.isbn, I.title_no
                  ORDER BY Title

                                        Return to TOC                                 19
Create View
Create a view in the TSQLFundamentals2008 database that returns the orderid,
day of the week (Spelled Out), the name of the month (spelled Out),
the day of the month, and the year based on the order date in the sales.orders table.

                   USE TSQLFundamentals2008;

                   IF OBJECT_ID('Sales.View1') IS NOT NULL
                     DROP VIEW Sales.View1;
                   GO
                   Create View Sales.View1
                   As
                   SELECT orderid
                            , DATENAME(WEEKDAY, orderdate) as "DAY"
                            , DATENAME(MONTH, orderdate) as "MONTH"
                            , DATENAME(DAY, orderdate) as "Date"
                            , DATENAME(YEAR, orderdate) as "Year"

                   FROM Sales.Orders




                                              Return to TOC                             20
Stored Procedure
Create a stored procedure in the TSQLFundamentals2008 database that returns the order ID,
the order date, the ship country. The employee full name, and the company name.
The ship country should be a parameter and the result set should be sorted by order date
from most recent to oldest.
                  USE TSQLFundamentals2008;

                  if OBJECT_ID('StoredProc1', 'P') IS NOT NULL
                            DROP PROC StoredProc1;

                  Go

                  CREATE PROC StoredProc1
                            @ShipCntry as varchar(20) = 'USA'
                  AS

                  SELECT S.orderid, S.orderdate, S.shipcountry

                  FROM Sales.Orders AS S
                            JOIN HR.Employees as E
                              on S.empid = E.empid
                            JOIN Sales.Shippers as Ship
                              ON Ship.shipperid = S.shipperid
                  WHERE S.shipcountry = @ShipCntry
                  Order BY S.orderdate

                                            Return to TOC                                   21
Piggy Bank Project
• The PiggyBank Database simulates bank operations such as Overdraft
  Accounts, Customer and Accounts relationships, and Transactions.

• This database has been used for a couple of projects:
   – Create an Entity Relationship Diagram given some specifications such
     as Overdraft Fees, Error Information when a transaction fails, Login
     Failures, and Customer/Account relationships.
   – Design back-end stored procedures, DDL/DML triggers, parameterized
     stored procedures that select from views. Some of the actions created
     are Create/Update Customer, Create Checking/Savings Accounts,
     Deposit/Withdrawal Procedures, Simulate ATM Balances, Customer
     Account History (bank statements) and Use of Overdraft Accounts.




                                 Return to TOC                           22
Piggy Bank Database Diagram




           Return to TOC      23
Piggy Bank Stored Proc Example




             Return to TOC       24
Piggy Bank DDL Example




         Return to TOC   25
Mini AdventureWorks Project
• The company Mini-AD (short for Mini-AdventureWorks) is interested in taking
  historical spreadsheet (CSV) data for their list of products, vendors, and
  purchase order history, and loading the data into a SQL Server database.
• Mini-AD wants the load process to work on a go-forward basis, so that
  new/modified products/vendors/orders can be loaded in SQL Server as well
• Mini-AD’s load process for orders should validate that any incoming orders with
  product numbers or vendor numbers that do not match an existing
  product/vendor number should NOT be written to the SQL Server database.
  Instead, this data should be written to an exception file and emailed.
• Mini-AD also wishes to build two reports : one for top vendor and product
  sales, and the second for sales by vendor and ship method across years.




                                 SSIS / SSRS Report Project                  26
MiniAD Database Diagram




         Return to TOC    27
Import Orders




    Return to TOC   28
Import Orders for Each Loop




           Return to TOC      29
Import Products Data Flow




          Return to TOC     30
Import Vendors




     Return to TOC   31
Update Product Prices




        Return to TOC   32
Top Vendors Report




       Return to TOC   33
Top Vendors Design




       Return to TOC   34
Vendor Sales by Year




        Return to TOC   35
Vendor Sales Design




       Return to TOC   36
BlockFlix Project
• As part of a team I helped develop a database
  complete with SSIS and SSRS services for a
  fictional movie rental company called “BlockFlix”
• The general requirements included the creation
  of a central, online database that handled movie
  rentals through online streaming
  video, kiosks, and brick-and-mortar stores.
• My primary responsibility involved using SSIS to
  import movie information into the DB from an
  XML file.
                       Return to TOC                  37
BlockFlix Database Diagram




           Return to TOC     38
Add Movies from XML
                   Phase One: Data Flow task
                                                 Also puts info into staging table
       Inserts Movie and Cast info directly
                                                  where Unique Keys weed out
           into their respective tables
                                                           duplications




                 Phase Two: Execute SQL Task
       Once the XML data has been refined, the SQL task inserts the info into the
        MovieCast table where Movies are associated with their respective cast
                                     members




                                 Phase Three
                   Run clean up to clear staging tables and save space.




       Return to TOC                                                          39
Inside the Dataflow Task              Get
                                        XML
                                         file



                    Convert XML to
                   correct data types


                  Send directly
                   to DB table




Capture
 errors
                  Return to TOC          40
Handling
the XML




           Return to TOC   41

Weitere ähnliche Inhalte

Ähnlich wie G Hslideshare2

Sql Portfolio(March 31)
Sql Portfolio(March 31)Sql Portfolio(March 31)
Sql Portfolio(March 31)iceolated
 
Greg Lewis SQL Portfolio
Greg Lewis SQL PortfolioGreg Lewis SQL Portfolio
Greg Lewis SQL Portfoliogregmlewis
 
Relational Database design.pptx
Relational Database design.pptxRelational Database design.pptx
Relational Database design.pptxjohndoe193402
 
A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.Alex Powers
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfoliolilredlokita
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and dataMilind Patil
 
Working with Joins - Understanding Oracle Joins
Working with Joins - Understanding Oracle JoinsWorking with Joins - Understanding Oracle Joins
Working with Joins - Understanding Oracle JoinsLuiscarlo Palomino Romero
 
More SQL in MySQL 8.0
More SQL in MySQL 8.0More SQL in MySQL 8.0
More SQL in MySQL 8.0Norvald Ryeng
 
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.Alex Powers
 
Library Project Stored Procs
Library Project Stored ProcsLibrary Project Stored Procs
Library Project Stored Procsnwbgh
 
Streams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupStreams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupBrian Cardiff
 

Ähnlich wie G Hslideshare2 (20)

Sql Portfolio(March 31)
Sql Portfolio(March 31)Sql Portfolio(March 31)
Sql Portfolio(March 31)
 
Greg Lewis SQL Portfolio
Greg Lewis SQL PortfolioGreg Lewis SQL Portfolio
Greg Lewis SQL Portfolio
 
Relational Database design.pptx
Relational Database design.pptxRelational Database design.pptx
Relational Database design.pptx
 
SQL Reports in Koha
SQL Reports in KohaSQL Reports in Koha
SQL Reports in Koha
 
Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 
Linked Lists Saloni
Linked Lists SaloniLinked Lists Saloni
Linked Lists Saloni
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.A "M"ind Bending Experience. Power Query for Excel and Beyond.
A "M"ind Bending Experience. Power Query for Excel and Beyond.
 
App B
App BApp B
App B
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and data
 
Working with Joins - Understanding Oracle Joins
Working with Joins - Understanding Oracle JoinsWorking with Joins - Understanding Oracle Joins
Working with Joins - Understanding Oracle Joins
 
dbms first unit
dbms first unitdbms first unit
dbms first unit
 
More SQL in MySQL 8.0
More SQL in MySQL 8.0More SQL in MySQL 8.0
More SQL in MySQL 8.0
 
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.A "M"ind Bending Experience. Power Query for Power BI and Beyond.
A "M"ind Bending Experience. Power Query for Power BI and Beyond.
 
Library Project Stored Procs
Library Project Stored ProcsLibrary Project Stored Procs
Library Project Stored Procs
 
My sql
My sqlMy sql
My sql
 
Streams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetupStreams of information - Chicago crystal language monthly meetup
Streams of information - Chicago crystal language monthly meetup
 
Year 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st TermYear 11 DATA PROCESSING 1st Term
Year 11 DATA PROCESSING 1st Term
 
Marcus Matthews
Marcus MatthewsMarcus Matthews
Marcus Matthews
 

Kürzlich hochgeladen

Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Nikki Chapple
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...amber724300
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsYoss Cohen
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...Karmanjay Verma
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Nikki Chapple
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 

Kürzlich hochgeladen (20)

Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
Microsoft 365 Copilot: How to boost your productivity with AI – Part two: Dat...
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
JET Technology Labs White Paper for Virtualized Security and Encryption Techn...
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Infrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platformsInfrared simulation and processing on Nvidia platforms
Infrared simulation and processing on Nvidia platforms
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...React JS; all concepts. Contains React Features, JSX, functional & Class comp...
React JS; all concepts. Contains React Features, JSX, functional & Class comp...
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
Microsoft 365 Copilot: How to boost your productivity with AI – Part one: Ado...
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 

G Hslideshare2

  • 1. Glenn Haertlein SQL Server Portfolio Phone: 864-385-8606 Email: glenn.haertlein@setfocus.com http://www.linkedin.com/in/htack210 1
  • 2. Table of Contents Introduction 3 What is Set Focus? 4 JungleBooks 5 Database Diagram 6 Single Table Query 7 Library 8 Query with Concatenation 9 Advanced Query with Joins 10 Query with Outer Join 11 Join/Union Query 12 Alternate to Previous Query 14 Query Using Temporary Table 16 Query Using Aggregate Function SUM 17 Query with Calculated Column 18 Create View 19 Stored Procedure 20 2
  • 3. ToC (cont’d) Piggy Bank 22 Database Diagram 23 Stored Proc Example (Make a deposit) 24 DDL Example 25 About Me 21 3
  • 4. Introduction •This portfolio contains examples of my development skills in MS SQL Server. It is a work in progress and reflects my current work thus far in the SetFocus Master’s Program. •SetFocus utilizes Microsoft Official Curriculum in conjunction with its own materials to produce some of the following coursework: • RDBMS and XML •Querying using Transact SQL •Implementing and maintaining a MS SQL Server 2005 Database •Designing an MS SQL Server 2005 Infrastructure •Designing security for MS SQL Server 2005 •Designing High Availability Database Solutions using MS SQL Server 2005 •Troubleshooting and Optimizing Database Servers using MS SQL Server 2005 •SQL Server Integration Services •SQL Server Reporting Services •In addition to the coursework and programming labs, the program includes challenging real-world projects where I apply the skills learned in class. Return to TOC 4
  • 5. What is SetFocus? • The SetFocus SQL Master’s Program is an intensive, hands-on, project-oriented program allowing knowledge and valuable experience putting the SQL skill set to use in a simulated work environment. • I am currently enrolled and will receive over 300 hours of in-depth, hands-on experience focused on SQL. • SetFocus projects are real world projects that are distributed just as I would receive in a position. I receive project specifications and am expected to identify best courses of action with deadlines set for completion. Return to TOC 5
  • 6. Junglebooks Scenario • Junglebooks is a book company which has a database consisting of books, authors, orders and customers. • For this project I created a database and submitted a database diagram. • In this project scenario, I am working with a fictitious application programmer who is building a client application using .NET. • To meet the needs of the application programmer, I created queries for different forms of the application. Return to TOC 6
  • 7. Database Diagram Return to TOC 7
  • 8. Single Table Query The Cheap Books form displays available books below a certain price. The user enters 15 in the txtUnitPrice form field. Return ISBN, title and publisher in order by title. USE JungleBooks; DECLARE @txtUnitPrice as int = 15; SELECT ISBN, Title, Publisher FROM JungleBooks.dbo.Books as Books WHERE Books.UnitPrice <= @txtUnitPrice ORDER BY Books.Title; Return to TOC 8
  • 9. Library Database Scenario The Library Database is created to support the principal functions of a lending library’s day-to-day operations. For this database project, I created queries against the Library database that returned a number of results using: • string concatenations • different types of joins • UNION statements • CASE statements • date manipulation • and aggregate functions. Return to TOC 9
  • 10. Query with String Concatenation Write and execute a query on the Member and Adult tables in the Library database that returns the firstname, middleinitial, lastname, street, city, state and zip. Concatenate the firstname, middleinitial and lastname columns into one string and alias as Name. Make sure that the spacing is appropriate when there is no middle initial due to a NULL or empty string value. Display records in order by lastname and firstname. USE library; SELECT M.firstname + ' ' + CASE WHEN M.middleinitial IS NULL THEN ' ' ELSE M.middleinitial + ' ' END + M.lastname As Name , A.street as [Street] , A.city as [City] , A.state as [State] , A.zip as [Zip] FROM member as M JOIN adult as A ON M.member_no = A.member_no ORDER BY M.lastname, M.firstname; Return to TOC 10
  • 11. Advanced Query Using Joins Write and execute a query on the Title, Item and Copy tables that returns the ISBN, copy_no, on_loan, title, translation, cover for rows in the copy table with an ISBN of 500 or 1000. Only available books should be displayed and hardback copies should be listed first. USE library; SELECT I.isbn , C.copy_no , C.on_loan , T.title , I.translation , I.cover FROM item as I JOIN copy as C ON I.isbn = C.isbn JOIN title as T ON C.title_no = T.title_no WHERE (C.on_loan = 'N' AND C.isbn = 500) or (C.on_loan = 'N' AND C.isbn = 1000) ORDER BY I.cover; Return to TOC 11
  • 12. Query with Outer Join Write and execute a query to retrieve the member’s full name and member_no from the Member table and the ISBN and log_date values from the Reservation table for member numbers 250, 341, and 1675. Order the results by member_no and log_date. You should show information for these members, even if they have no books on reserve. USE library; SELECT M.member_no , M.firstname + ' ' + CASE WHEN M.middleinitial IS NULL THEN ' ' ELSE M.middleinitial + ' ' END + M.lastname as Name , R.isbn , CAST(R.log_date as DATE) as log_date FROM member as M LEFT OUTER JOIN reservation as R ON M.member_no = R.member_no WHERE m.member_no IN (250, 341, 1675) ORDER BY m.member_no, r.log_date; Return to TOC 12
  • 13. USE library; SELECT I.isbn Join/Union Query ,T.title ,A.member_no ,M.lastname + ', ' + M.firstname + ' ' + Write and execute a query to CASE WHEN M.middleinitial IS NULL THEN ' ' retrieve the member’s full ELSE M.middleinitial + ' ' END as FullName, name and member_no from 'Adult' as [Status] the Member table and the FROM adult as A JOIN member as M ISBN and log_date values ON A.member_no = M.member_no from the Reservation table JOIN reservation as R ON R.member_no = A.member_no for member numbers 250, JOIN item as I ON I.isbn = R.isbn 341, and 1675. Order the JOIN title as T results by member_no and ON T.title_no = I.title_no WHER E I.isbn = '288' log_date. You should show UNION ALL information for these SELECT I.isbn members, even if they have ,T.title ,J.member_no no books on reserve. ,M.lastname + ', ' + M.firstname + ' ' + CASE WHEN M.middleinitial IS NULL THEN ' ' ELSE M.middleinitial + ' ' END as FullName, 'Juvenile' as [Status] FROM Juvenile as J JOIN member as M ON J.member_no = M.member_no JOIN reservation as R ON R.member_no = J.member_no JOIN item as I ON I.isbn = R.isbn JOIN title as T ON T.title_no = I.title_no Return to TOC 13 WHERE I.isbn = '288'
  • 14. Query Proof Return to TOC 14
  • 15. Alternate to Previous Query USE library; SELECT DISTINCT I.isbn ,T.title ,M.member_no Write the above statement ,M.lastname + ', ' + M.firstname + ' ' + again using a CASE statement. CASE You cannot JOIN to the Adult WHEN M.middleinitial IS NULL THEN ' ' ELSE M.middleinitial + ' ' or Juvenile tables. Compare END as FullName, the two versions and [Status] = CASE determine which one is more WHEN EXISTS (SELECT * FROM dbo.adult WHERE dbo.adult.member_no=m.member_no) THEN 'Adult' efficient. Cut and paste the ELSE 'Juvenile' proof of your research. (No END FROM need to copy the output of member as M records) JOIN reservation as R ON R.member_no = M.member_no JOIN item as I ON I.isbn = R.isbn JOIN title as T ON T.title_no = I.title_no WHERE R.isbn = '288' ORDER BY FullName Return to TOC 15
  • 16. Query Proof Return to TOC 16
  • 17. Query Using Temporary Table to Store Records Write and execute a query that returns the member_no, full name, out_date, due_date, and title columns from the Loan, Member, and Title tables. Convert the datetime values from the out_date and due_date columns to char(12), format 101. Restrict the results to books which were due prior to the current date. Load the records into a temporary table called #overdue. Leave the query window open after you create the temporary table. USE library; IF OBJECT_ID('tempdb.dbo.#overdue') IS NOT NULL DROP TABLE dbo.#overdue; GO SELECT M.member_no , M.firstname + ' ' + CASE WHEN M.middleinitial IS NULL THEN ' ' ELSE M.middleinitial + ' ' END + ' ' + M.lastname as FullName , CONVERT(char(12), L.out_date, 101) as [Out Date] , CONVERT(char(12), L.due_date, 101) as [Due Date] , T.title INTO dbo.#overdue FROM loan as L JOIN member as M ON L.member_no = M.member_no JOIN title as T ON T.title_no = L.title_no WHERE due_date < CURRENT_TIMESTAMP Return to TOC ORDER BY FullName; 17
  • 18. Query Using Aggregate Function SUM Write and execute a query that returns member_no, firstname, lastname and sum of fine_paid for members who have paid the highest fines to date. Members should only appear once in the list. Display the highest fine first. If more than one member has paid the same amount display the records in order by member_no. USE library; SELECT M.member_no , M.firstname , M.Lastname , CAST(SUM(LH.fine_paid) as Numeric(5,2)) as FinePaid FROM member as M JOIN loanhist as LH ON M.member_no = LH.member_no GROUP BY M.member_no, M.firstname, M.lastname HAVING SUM(LH.fine_paid) IS NOT NULL ORDER BY FinePaid DESC, M.member_no; Return to TOC 18
  • 19. Query with Calculated Column Write and execute a query on the Reservation table that returns the ISBN, title and Total. The Total column is a calculated column which represents the number of members wishing to reserve a particular book. USE library; SELECT R.isbn ,(SELECT T.title FROM title as T WHERE I.title_no = T.title_no) as Title , COUNT(R.member_no) as Total FROM reservation as R JOIN item as I ON I.isbn = R.isbn GROUP BY R.isbn, I.title_no ORDER BY Title Return to TOC 19
  • 20. Create View Create a view in the TSQLFundamentals2008 database that returns the orderid, day of the week (Spelled Out), the name of the month (spelled Out), the day of the month, and the year based on the order date in the sales.orders table. USE TSQLFundamentals2008; IF OBJECT_ID('Sales.View1') IS NOT NULL DROP VIEW Sales.View1; GO Create View Sales.View1 As SELECT orderid , DATENAME(WEEKDAY, orderdate) as "DAY" , DATENAME(MONTH, orderdate) as "MONTH" , DATENAME(DAY, orderdate) as "Date" , DATENAME(YEAR, orderdate) as "Year" FROM Sales.Orders Return to TOC 20
  • 21. Stored Procedure Create a stored procedure in the TSQLFundamentals2008 database that returns the order ID, the order date, the ship country. The employee full name, and the company name. The ship country should be a parameter and the result set should be sorted by order date from most recent to oldest. USE TSQLFundamentals2008; if OBJECT_ID('StoredProc1', 'P') IS NOT NULL DROP PROC StoredProc1; Go CREATE PROC StoredProc1 @ShipCntry as varchar(20) = 'USA' AS SELECT S.orderid, S.orderdate, S.shipcountry FROM Sales.Orders AS S JOIN HR.Employees as E on S.empid = E.empid JOIN Sales.Shippers as Ship ON Ship.shipperid = S.shipperid WHERE S.shipcountry = @ShipCntry Order BY S.orderdate Return to TOC 21
  • 22. Piggy Bank Project • The PiggyBank Database simulates bank operations such as Overdraft Accounts, Customer and Accounts relationships, and Transactions. • This database has been used for a couple of projects: – Create an Entity Relationship Diagram given some specifications such as Overdraft Fees, Error Information when a transaction fails, Login Failures, and Customer/Account relationships. – Design back-end stored procedures, DDL/DML triggers, parameterized stored procedures that select from views. Some of the actions created are Create/Update Customer, Create Checking/Savings Accounts, Deposit/Withdrawal Procedures, Simulate ATM Balances, Customer Account History (bank statements) and Use of Overdraft Accounts. Return to TOC 22
  • 23. Piggy Bank Database Diagram Return to TOC 23
  • 24. Piggy Bank Stored Proc Example Return to TOC 24
  • 25. Piggy Bank DDL Example Return to TOC 25
  • 26. Mini AdventureWorks Project • The company Mini-AD (short for Mini-AdventureWorks) is interested in taking historical spreadsheet (CSV) data for their list of products, vendors, and purchase order history, and loading the data into a SQL Server database. • Mini-AD wants the load process to work on a go-forward basis, so that new/modified products/vendors/orders can be loaded in SQL Server as well • Mini-AD’s load process for orders should validate that any incoming orders with product numbers or vendor numbers that do not match an existing product/vendor number should NOT be written to the SQL Server database. Instead, this data should be written to an exception file and emailed. • Mini-AD also wishes to build two reports : one for top vendor and product sales, and the second for sales by vendor and ship method across years. SSIS / SSRS Report Project 26
  • 27. MiniAD Database Diagram Return to TOC 27
  • 28. Import Orders Return to TOC 28
  • 29. Import Orders for Each Loop Return to TOC 29
  • 30. Import Products Data Flow Return to TOC 30
  • 31. Import Vendors Return to TOC 31
  • 32. Update Product Prices Return to TOC 32
  • 33. Top Vendors Report Return to TOC 33
  • 34. Top Vendors Design Return to TOC 34
  • 35. Vendor Sales by Year Return to TOC 35
  • 36. Vendor Sales Design Return to TOC 36
  • 37. BlockFlix Project • As part of a team I helped develop a database complete with SSIS and SSRS services for a fictional movie rental company called “BlockFlix” • The general requirements included the creation of a central, online database that handled movie rentals through online streaming video, kiosks, and brick-and-mortar stores. • My primary responsibility involved using SSIS to import movie information into the DB from an XML file. Return to TOC 37
  • 38. BlockFlix Database Diagram Return to TOC 38
  • 39. Add Movies from XML Phase One: Data Flow task Also puts info into staging table Inserts Movie and Cast info directly where Unique Keys weed out into their respective tables duplications Phase Two: Execute SQL Task Once the XML data has been refined, the SQL task inserts the info into the MovieCast table where Movies are associated with their respective cast members Phase Three Run clean up to clear staging tables and save space. Return to TOC 39
  • 40. Inside the Dataflow Task Get XML file Convert XML to correct data types Send directly to DB table Capture errors Return to TOC 40
  • 41. Handling the XML Return to TOC 41