kevin bengtson portfolio

46
SQL Portfolio Kevin Bengtson [email protected] 763-898-3453

Upload: kbengt521

Post on 17-May-2015

1.618 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Kevin Bengtson Portfolio

SQL Portfolio

Kevin [email protected]

Page 2: Kevin Bengtson Portfolio

Table of Contents

• PiggyBank Project – Database T-SQL design• Junglebooks T-SQL Queries• Library T-SQL Queries• SQL Server Administative Tasks Project• MiniAdventureWorks SSIS/SSRS• BlockFlix Final Group Project• What is SetFocus?

Page 3: Kevin Bengtson Portfolio

Piggybank Project

• Introduction: Given a set of columns to be used in a banking database, determine which columns are necessary. Create the database using SSMS.

• Project Goals: Develop a database and the appropriate Stored Procedures to access the data. Create testscripts to test the procecdures

Page 4: Kevin Bengtson Portfolio

Project Sample – Database Diagram

Page 5: Kevin Bengtson Portfolio

Project Sample – Create Account• USE [PiggyBank1]• GO

• /****** Object: Table [dbo].[Account] Script Date: 04/01/2010 15:53:47 ******/• SET ANSI_NULLS ON• GO

• SET QUOTED_IDENTIFIER ON• GO

• CREATE TABLE [dbo].[Account](• [AccountID] [int] IDENTITY(1,1) NOT NULL,• [AccountTypeID] [tinyint] NOT NULL,• [AccountStatusID] [tinyint] NOT NULL,• [CurrentBalance] [money] NOT NULL,• [OverDraftAccountID] [int] NULL,• [GeneralOverdraft] [bit] NULL,• CONSTRAINT [PK_Account] PRIMARY KEY CLUSTERED • (• [AccountID] ASC• )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]• ) ON [PRIMARY]• GO

• ALTER TABLE [dbo].[Account] WITH CHECK ADD CONSTRAINT [FK_Account_AccountStatus] FOREIGN KEY([AccountStatusID])• REFERENCES [dbo].[AccountStatus] ([AccountStatusID])• GO

• ALTER TABLE [dbo].[Account] CHECK CONSTRAINT [FK_Account_AccountStatus]• GO

• ALTER TABLE [dbo].[Account] WITH CHECK ADD CONSTRAINT [FK_Account_AccountType] FOREIGN KEY([AccountTypeID])• REFERENCES [dbo].[AccountType] ([AccountTypeID])• GO

• ALTER TABLE [dbo].[Account] CHECK CONSTRAINT [FK_Account_AccountType]• GO

Page 6: Kevin Bengtson Portfolio

Project Sample – Create Customer• USE [PiggyBank1]• GO

• /****** Object: Table [dbo].[Customer] Script Date: 04/01/2010 15:52:43 ******/• SET ANSI_NULLS ON• GO

• SET QUOTED_IDENTIFIER ON• GO

• SET ANSI_PADDING ON• GO

• CREATE TABLE [dbo].[Customer](• [CustomerID] [int] IDENTITY(1,1) NOT NULL,• [CustomerFirstName] [varchar](20) NOT NULL,• [CustomerLastName] [varchar](30) NOT NULL,• [CustomerMiddleInitial] [varchar](1) NULL,• [Street] [varchar](50) NOT NULL,• [City] [varchar](20) NOT NULL,• [State] [char](2) NOT NULL,• [ZipCode] [char](10) NOT NULL,• [Email] [varchar](30) NULL,• [HomePhone] [char](12) NOT NULL,• [WorkPhone] [char](12) NULL,• [CellPhone] [char](12) NULL,• CONSTRAINT [PK_Customer] PRIMARY KEY CLUSTERED • (• [CustomerID] ASC• )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]• ) ON [PRIMARY]

• GO

• SET ANSI_PADDING OFF• GO

Page 7: Kevin Bengtson Portfolio

Project Sample – ATMGetTransactions

• USE [PiggyBank1]• GO

• /****** Object: StoredProcedure [dbo].[ATMGetTransactions] Script Date: 04/01/2010 16:08:33 ******/• SET ANSI_NULLS ON• GO

• SET QUOTED_IDENTIFIER ON• GO

• --=============================================• -- ATMGetTransactions• -- Author: Kevin Bengtson• -- Create date: 1/26/2010• -- Description: Get the transaction history for• -- the last 30 days• -- =============================================• create procedure [dbo].[ATMGetTransactions]• -- The set of input parameters.• @AccountID int• as• begin• select convert(varchar(30), t.TransactionDate, 101) as Date, t.TransactionTypeName as Type, t.TransactionAmount, t.NewBalance • from dbo.v_Transaction_Info t• where t.AccountID = @AccountID AND t.TransactionDate >= DATEADD(day, -30, getdate())• order by t.TransactionDate desc• end

• GO

• GO

Page 8: Kevin Bengtson Portfolio

Project Sample – Screenshot testscripts

Page 9: Kevin Bengtson Portfolio

T-SQL Queries Project

• Introduction: Given two databases, Library and Junglebooks, deliver T-SQL Queries to perform specific functions.

• Project Goals: Develop Queries to access the data and print it out.

Page 10: Kevin Bengtson Portfolio

T-SQL Queries Project - Samples• Introduction: Given two databases, Library and Junglebooks, deliver Queries to perform specific functions.• use JungleBooks

• --TSQL1 #1

• SELECT ISBN, title, publisher • FROM dbo.Books• WHERE UnitPrice < 15• ORDER BY title

• --TSQL1 #2

• SELECT Name as 'Search Results' • FROM dbo.Authors• WHERE LOWER(name) like '%pet%'• ORDER BY Name

• --TSQL1 #3• SELECT • CustomerId as 'Cust ID',• OrderId as 'Order #',• OrderDate as 'Order Date'• FROM dbo.Orders• WHERE CustomerId BETWEEN 6 and 15• ORDER BY CustomerId•

• Project Goals: Develop Queries to access the data and print it out. Create testscripts to test the procecdures

Page 11: Kevin Bengtson Portfolio

T-SQL Queries Project - Samples

• use library

• -- Task 1

• select m.firstname + ' ' + m.middleinitial + ' ' + m.lastname as Name,• a.street, • a.city,• a.state,• a.zip• from dbo.adult a inner join dbo.member m• on a.member_no = m.member_no• -- where m.middleinitial is not null• order by m.lastname, m.firstname

• -- Task 2

• select i.isbn,• c.copy_no,• c.on_loan,• t.title as Title,• i.translation,• i.cover• from dbo.item i inner join dbo.copy c• on i.isbn = c.isbn• inner join dbo.title t• on c.title_no = t.title_no• where (i.isbn = 500 or i.isbn = 1000) AND• c.on_loan <> 'Y'• order by i.cover

Page 12: Kevin Bengtson Portfolio

T-SQL Queries Project - Screenshots

Page 13: Kevin Bengtson Portfolio

T-SQL Queries Project - Screenshots

Page 14: Kevin Bengtson Portfolio

SQL Server Administrative Tasks

Introduction : Project includes implementing different including :

• Install and Configure SQL Server 2008 Practical Exercise• Manage Database Files• Resizing Files and Modifying Database Properties• Policy-Based Management• Implementing Disaster Recovery Procedures• Database Snapshots• Working with Schemas• Implementing Security• Schema Permissions

Page 15: Kevin Bengtson Portfolio

SQL Server Administrative Tasks

• Auditing Database Role Membership• Exporting and Importing Data• Weekly Integrity Checks• Transaction Log Approaching Capacity• Monitoring CREATE TABLE statements• Ownership Chaining• Resource Governor• Data Collector• Database Mirroring• Replication

Page 16: Kevin Bengtson Portfolio

Administrative Tasks Screenshots

Page 17: Kevin Bengtson Portfolio

Administrative Tasks Screenshots

Page 18: Kevin Bengtson Portfolio

Administrative Tasks Screenshots

Page 19: Kevin Bengtson Portfolio

Administrative Tasks Screenshots

Page 20: Kevin Bengtson Portfolio

Administrative Tasks Screenshots Query History Report

Page 21: Kevin Bengtson Portfolio

Administrative Tasks Screenshots Query History Report

Page 22: Kevin Bengtson Portfolio

SSIS-SSRS-TSQL Project

Introduction : Create MiniAdventureWorksDB Database using SSIS. Build Routines in SSIS to execute procedures.

Page 23: Kevin Bengtson Portfolio

SSIS-SSRS-TSQL Project

• SSIS Project Packages• CreateDatabase.dtsx• ImportProducts.Dtsx• ImportVendors.Dtsx• ImportShipMethod.Dtsx• ImportOrders.Dtsx• MasterPackage.Dtsx

Page 24: Kevin Bengtson Portfolio

SSIS-SSRS-TSQL Project

• SSRS Report Packages• rptTopSales.rdl• rptSalesMatrixByYear.rdl

Page 25: Kevin Bengtson Portfolio

SIS-SSRS-TSQL Project Screenshots

Page 26: Kevin Bengtson Portfolio
Page 27: Kevin Bengtson Portfolio

Team Members: Kevin Puls – Project ManagerKevin Bengtson – Assistant Project ManagerJose SuarezVincent Doyle

Page 28: Kevin Bengtson Portfolio

BlockFlix Database Layout

*No deletes allowed on transaction table

Page 29: Kevin Bengtson Portfolio

• XML file example

• Add Movie SSIS Demo

XML Movie Import

Page 30: Kevin Bengtson Portfolio

XML Movie Import - Functions

• Usp_AddMovie• Input movie title, year, genre ID, and rating ID• Will not re-enter duplicate

• Usp_AddCast• Input cast member first and last name• Will not re-enter duplicates

• Usp_AddMovieCast• Input movie ID, cast ID, and cast type ID• Will not re-enter duplicates

• Usp_AddInventory• Input movie ID, location ID, inventory type ID, rentable,

quantity, cost, and condition ID

Page 31: Kevin Bengtson Portfolio

Transaction Procedure – Usp_RentMovie

Page 32: Kevin Bengtson Portfolio

Transaction Procedure – Usp_RentMovie (Page 2)

Page 33: Kevin Bengtson Portfolio

Additional Transaction Procedures

• Usp_ReturnMovie• Input SKU• Returns movie to inventory (Set quantity back to 1)• Subtracts 1 from the account’s checked-out amount

• Usp_BuyMovie• Input SKU• Optional Input Customer ID and Account ID• Make an entry for the Transaction table• Remove from the Inventory table• Delete movie from database if not copies are available

• Usp_MoveSell• Input SKU• Put a rented item up for sale • Will not work for Kiosks

Page 34: Kevin Bengtson Portfolio

Account Payment Procedures - Usp_LostInventory

Page 35: Kevin Bengtson Portfolio

Account Payment Procedures - Usp_LostInventory (Page2)

Page 36: Kevin Bengtson Portfolio

• Usp_MakeOverdue• Queries all active accounts• Closes accounts that are 30 days overdue

• Usp_MakePayment• Input customer ID, account ID, transaction type ID• Determine membership type / fee amount • Update fee balance in account table• Reopens account if balance is paid in full

Additional Account Payment Procedures

Page 37: Kevin Bengtson Portfolio

• Usp_CreateCustomer• Input first name, last name, middle initial, street, city,

state, zip code, e-mail, phone

• Usp_ModifyCustomer• Input first name, last name, middle initial, street, city,

state, zip code, e-mail, phone

• Usp_CreateAccount• Input customer ID, membership type ID, account status ID

• Usp_ModifyAccount• Input customer ID, membership type ID, account status ID

Customer Account Procedures

Page 38: Kevin Bengtson Portfolio

• Usp_QueueAdd• Input account ID and list ID (Movie or game ID)• Adds a game or movie to an account’s queue

• Usp_QueueAdjust• Input account ID, list ID 1, list ID 2 • Swaps the positions of two items in a queue

• Usp_QueueSubtract• Input account ID and list ID• Removes a game or movie from an account’s queue• Reorders the remaining items in the queue

Customer Account Procedures (Page 2)

Page 39: Kevin Bengtson Portfolio

Requested Reports

Page 40: Kevin Bengtson Portfolio

Requested Reports (Page 2)

Page 41: Kevin Bengtson Portfolio

Requested Reports (Page 3)

• Usp_ShowMovieInventory• Input location ID• Returns a list of all movies at the given location

Page 42: Kevin Bengtson Portfolio

• Full Backup• Every week

• Differential Backup• Every day

• Transaction Backup• Every 1 hour

• Rebuild Indexes• Every week

• Update Statistics• Every week

• Clean History• Every week

• Maintenance Cleanup• Every week

Backup and Maintenance Plan

Page 43: Kevin Bengtson Portfolio

• Dell PowerEdge 11G R610• Two Quad-Core Intel® Xeon® 5500 series processors • 96GB (12 DIMM slots/6 per-processor): 8GB DDR3

1333MHz memory • Windows Server® 2008 R2 Enterprise

• Datacenter Cluster• 12 Server blades • 48 Gigs of RAM per blade• 3 TB of storage per blade• Windows Server® 2008 R2 Datacenter

Page 44: Kevin Bengtson Portfolio

• Data uploading to BlockFlix Master• SSIS nightly uploads• Upload all

– Transactions – Inventory/Inventory Lost– New customer information

• Full Game functionality • All the same functions that are available to movies

Unimplemented Components

Page 45: Kevin Bengtson Portfolio

• Video Streaming • Separate server with large disk space to store the

movies in and filestream them out. • Database would need to be changed to keep track of

Video Stream movies.

• Throttling• Database modification is already in place• Modification of Usp_RentMovie is needed

• Movie Search• Be able to do a fuzzy search on Title or Cast Name and

return all movies

Possible Expansion

Page 46: Kevin Bengtson Portfolio

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 received over 300 hours of in-depths hands on experience

focused on SQL Development.

• SetFocus projects are real world projects that are distributed just as I would receive in a position. I received project specifications and was expected to identify best courses of action with deadlines set for completion.