Successfully reported this slideshow.

My Portfolio


Published on

Samples of work from SetFocus classes

  • Be the first to comment

My Portfolio

  1. 1. Name: Doug McGlasson Email: [email_address] Phone: (281) 853-4217
  2. 2. <ul><li>Introduction </li></ul><ul><li>RDBMS Project </li></ul><ul><ul><li>ER Diagram </li></ul></ul><ul><li>Bank Project </li></ul><ul><ul><li>ER Diagram </li></ul></ul><ul><ul><li>Stored procedure- samples </li></ul></ul><ul><ul><li>Triggers </li></ul></ul>Table of Contents
  3. 3. <ul><li>Library Project </li></ul><ul><ul><li>ER Diagram </li></ul></ul><ul><ul><li>Stored procedure samples </li></ul></ul><ul><ul><li>SSRS Report - samples </li></ul></ul><ul><li>Online Movie Project </li></ul><ul><ul><li>ER Diagram </li></ul></ul><ul><ul><li>SSIS Sample </li></ul></ul><ul><ul><li>SSRS Sample report </li></ul></ul><ul><ul><li>Backup and Recovery Plan </li></ul></ul><ul><ul><li>Security Considerations </li></ul></ul>Table of Contents - cont.
  4. 4. <ul><li>This portfolio contains examples of my development work on a variety of real-world projects. The projects were part of a 13-week hands-on training course with the SetFocus Masters Program. </li></ul><ul><li>SetFocus utilizes Microsoft Official Curriculum in conjunction with its own materials in the following areas: </li></ul><ul><ul><li>RDBMS </li></ul></ul><ul><ul><li>Querying using T-SQL </li></ul></ul><ul><ul><li>SQL Server Integration Services </li></ul></ul><ul><ul><li>SQL Server Reporting Services </li></ul></ul><ul><ul><li>Implementing and maintaining a SQL Server 2005 database </li></ul></ul>Introduction
  5. 5. RDBMS Project This project provided a list of columns and business rules that are to be used as a guide for development of the proposed PiggyBank database. The goal is a database in the third normal form but the developer is allowed to denormalize for a valid business reason. The column list that is provided has redundancies and new columns may be necessary. The developer is to make the best choices for primary and foreign key constraints. The expected deliverable is an ER diagram with crows-foot notation.
  6. 6. RDBMS - ER Diagram
  7. 7. Bank Project We are given a modified version of the ER diagram we developed earlier and tasked with developing stored procedures for the following: Create new customer and update customer Create new account (savings or checking), update account status and add user Change account status, close account, reactivate account Deposit, Withdrawal and Transfer Overdraft setup (general and specific accounts) ATM procedures Show balance for last five transactions Show transaction history for the last 30 days Additionally create a trigger to prevent drop and alteration of tables plus a trigger to prevent deletes and updates to the transaction table (and any others deemed necessary)
  8. 8. Bank Project - ER Diagram
  9. 9. Bank Project – Try/Catch Block BEGIN TRY -validate parameters - -state codes are used to send outcome to the caller BEGIN TRANSACTION -set Nocount on to prevent extra results from interfering with select statements BEGIN -body of procedure END COMMIT TRANSACTION END TRY BEGIN CATCH . IF @@TRANCOUNT>0 ROLLBACK TRANSACTION --Declare local variables to hold the error passed back to the caller DECLARE @ERRORMESSAGE NVARCHAR(4000); DECLARE @ERRORSEVERITY INT; DECLARE @ERRORSTATE INT; -- Set the variables to the error values SELECT @ERRORMESSAGE = ERROR_MESSAGE(), @ERRORSEVERITY = ERROR_SEVERITY(), @ERRORSTATE = ERROR_STATE(); --Raise the error to the caller with the error variables RAISERROR (@ERRORMESSAGE, @ ERRORSEVERITY,@ERRORSTATE) END CATCH
  10. 10. Bank Project – New Account Procedure BEGIN TRANSACTION -- INSERT INTO ACCOUNT TABLE B EGIN BEGIN INSERT account (AccountTypeID, AccountStatusID,CurrentBalance, O verDraftAccountID, GeneralOverDraft) VALUES (@AccountTypeID, 1, @InitialAmount, @OverDraftAccountID, @GeneralOverDraft) END --Declare local variable to hold the new AccountID -to be used to add new records to the Transactions and CustomerAccount tables declare @newAccountNo int --Set the value to the new AccountID set @newAccountNo=scope_identity() BEGIN -- INSERT INTO TRANSACTIONS TABLE INSERT TRANSACTIONS (AccountID, TransactionTypeID, CustomerID, TransactionDate, TransactionAmount, NewBalance) Values (@NewAccountNo, 1, @CustomerID, getdate(), @InitialAmount, @InitialAmount) END BEGIN --INSERT INTO CUSTOMERACCOUNT TABLE INSERT CustomerAccount (AccountID, CustomerID) VALUES (@newAccountNo, @CustomerID) END END COMMIT TRANSACTION
  11. 11. Bank Project – Transfer Funds Procedure BEGIN TRANSACTION SET NOCOUNT ON; declare @BeginOutBalance money set @BeginOutBalance=( SELECT CurrentBalance FROM Account WHERE Accountid=@FromAccountID) BEGIN INSERT Transactions (AccountID, TransactionTypeId, CustomerID, TransactionDate, TransactionAmount, NewBalance) VALUES (@FromAccountId, 4, @CustomerID, Getdate(), @TransferAmount, @BeginOutBalance-@TransferAmount) END DECLARE @NewOutbalance INT SET @NewOutBalance=(@BeginOutBalance-@TransferAmount) BEGIN Update Account SET CurrentBalance=@NewOutBalance WHERE AccountID=@FromAccountID END DECLARE @BeginInBalance money SET @BeginInBalance=( SELECT CurrentBalance FROM Account WHERE Accountid=@ToAccountID) BEGIN INSERT Transactions (AccountID, TransactionTypeId, CustomerID, TransactionDate, TransactionAmount, NewBalance) VALUES (@ToAccountId, 5, @CustomerID, Getdate(), @TransferAmount, @BeginInBalance+@TransferAmount) END DECLARE @NewInBalance INT SET @NewInBalance=(@BeginInBalance+@TransferAmount) BEGIN Update Account SET CurrentBalance=@NewInBalance WHERE AccountID=@ToAccountID END COMMIT TRANSACTION
  12. 12. Bank Project – DDL Trigger CREATE TRIGGER tgr_ddl_safe ON DATABASE FOR ALTER_VIEW, DROP_VIEW, ALTER_TABLE, DROP_TABLE AS BEGIN SET NOCOUNT ON --Throw an error RAISERROR('You may not drop or alter database objects.',11,1) IF @@TRANCOUNT>0 BEGIN ROLLBACK TRANSACTION END END
  13. 13. Bank Project – DML Trigger CREATE TRIGGER [dbo].[delTransactions] on [dbo].[Transactions] INSTEAD OF DELETE, UPDATE AS BEGIN SET NOCOUNT ON; DECLARE @DeleteCount int; SELECT @DeleteCount=Count(*) from Deleted; if @DeleteCount>0 BEGIN RAISERROR (N'Transactions cannot be deleted or updated.', 10,1); IF @@TRANCOUNT >0 BEGIN ROLLBACK TRANSACTION; END END; END;
  14. 14. Library Project A database has been created to support the principal functions of a lending library’s day-to-day operations: adding new members (adult and juvenile), checking books out and in, adding new books, renewing memberships, changing a juvenile record to an adult record once the juvenile reaches 18 and updating adult record information. Books are identified by International Standard Book Number (ISBN). Books with the same title will have different ISBN based upon language and cover type. The library also holds multiple copies of each ISBN. Loan history is considered critical information and must be kept indefinitely. Library memberships are good for one year from issue date. Adults are issued memberships and juveniles are associated with an adult sponsor until they reach 18. Books are checked out for 14 days and members may have only 4 books out at any one time. The deliverable is to create stored procedures to support system functionality and any necessary views and a variety of reports that can be viewed online.
  15. 15. Library Project - ER Diagram
  16. 16. Library Project – Add New Member Proc BEGIN TRANSACTION BEGIN INSERT MEMBER (LastName, FirstName, MiddleInitial, Photograph) Values (@LastName, @FirstName, @MiddleInitial, @Photograph) END if @@error<> 0 Begin print'Member name information failed' ROLLBACK TRANSACTION Return -8 End Set @newidentity=scope_identity() --STATE HAS DEFAULT CONSTRAINT If @state is null BEGIN INSERT ADULT (Member_no, Street, City, Zip, Phone_no, Expr_date) VALUES (@newidentity, @Street, @City, @Zip, @Phone_no, getdate()+365) END ELSE BEGIN INSERT ADULT (Member_no, Street, City, State, Zip, Phone_no, Expr_date) VALUES (@newidentity, @Street, @City, @State, @Zip, @Phone_no,getdate()+ 365) END if @@error<>0 BEGIN PRINT 'Address insert failed' ROLLBACK TRANSACTION RETURN -9 END Set @member_no=@NEWIDENTITY -- To populate the output parameter COMMIT TRANSACTION RETURN 0 -- SUCCESS
  17. 17. Library Project – Check in Item Proc BEGIN TRANSACTION BEGIN UPDATE copy SET on_loan='N'where isbn=@isbn and copy_no=@copy_no END BEGIN INSERT LOANHIST SELECT @isbn,@copy_no,out_date,title_no,member_no, due_date,getdate(),NULL, NULL,NULL,NULL from loan where isbn=@isbn and copy_no=@copy_no END BEGIN delete loan where @isbn=isbn and @copy_no=copy_no END COMMIT TRANSACTION
  18. 18. Library Project – Kids Club Report   Beginning Reader June 28 Barr, Angela S Beginning Reader June 28 Barr, Angela K Junior Reader June 28 Anderson, Karl B Junior Reader June 28 Anderson, Jose H Reading Ace August 17 Anderson, Jose A Junior Reader June 28 Anderson, Frank Y Notes Birthday Member Name                                                             7 years old   8 years old   9 years old   Legend:                                     The Kids Club                                    
  19. 19. Library Project – Kids Club Procedure SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROC [dbo].[uspKidsClub] AS SELECT (Lastname+', '+firstname+' '+middleinitial) AS membername, cast(datediff(day,(birth_date+.5),Getdate())/(365.25)AS int) AS age, datename(month,Birth_date) AS birthMonth, day(Birth_date) AS DayOfBirth, juvenile.member_no FROM juvenile inner Join member ON member.member_no=juvenile.member_no WHERE datediff(day,(birth_date+.5),Getdate())/(365.25) between 7 and 10 ORDER BY memberName GO
  20. 20. Library Project – Most Active Report   4 2009 January 66 Anderson, Linda B   4 2009 January 16 Anderson, Michael A Active Reader 6 2009 January 860 Barr, Angela G Active Reader 9 2009 January 2029 Chen, Amy A Active Reader 9 2009 January 516 Anderson, Shelly R Avid Reader 10 2009 January 2609 Chen, Gary T Avid Reader 11 2009 January 5547 Harui, Gary E Avid Reader 12 2009 January 4955 Graff, Mary Anne H Avid Reader 12 2009 January 302 Anderson, Michael K Reader Status No of checkouts Year Month Member Number Member Name                         For Member Activity January 2009                               Most Active Members Report                               The Library Project                            
  21. 21. Library Project – Most Active Procedure CREATE proc [dbo].[uspCheckoutHist] (@Year varchar(4), @Month varchar(15)) AS SELECT (member.lastname+', '+ member.firstname+' '+member.middleInitial) as Fullname, count(out_date)as No_of_checkouts, dateNAME(mm,out_date) as Month, datepart(month,out_date) as mo_int, datepart(year,out_date) as [Year], loanhist.member_no FROM loanhist inner join member ON member.member_no=loanhist.member_no WHERE datepart(year,out_date)=@Year and dateNAME(mm,out_date)=@Month GROUP BY l oanhist.member_no,datename(mm,out_date),datepart(year,out_date), datepart( month,out_date), (member.lastname+', '+ member.firstname+' '+member.middleInitial) ORDER BY count(out_date) DESC,member_no,year desc, mo_int asc
  22. 22. Online Movie Project The online movie rental company, BlockFlix, has stores nationwide and is creating a centralized database for tracking inventory, sales, customers and memberships. The stores rent VHS movies, DVD’s and video games as well as selling new and used movies, movie memorabilia, games, game consoles, snack foods and drinks. A new website will be created that uses the database to rent movies online. Database access must be through stored procedures. All inventory is received at one location and distributed to stores. Stores have ancillary kiosk locations in supermarkets and other retail locations that allow member or non-member rentals at $ 1.00 per day per movie. Online and store customers purchase a yearly membership at one of six levels with right to a certain number of movies out at any one time based upon their membership level. Additionally each member will have a queue of movies they would like to be mailed to them as they return movies as specified by their membership level. Management is expecting a high-availability database solution and mandate that all transactions are to be stored indefinitely within the database.
  23. 32. <ul><li>Implementation of Mirroring between headquarters server and Mirror server located off site </li></ul><ul><li>Off site location for archive server to hold legacy data and static information and also acts as the witness for the Mirroring solution </li></ul><ul><ul><li>The Archive server will be configured as a linked server to both the Principal and the Mirror servers to enable reporting access. </li></ul></ul><ul><li>Implementation of RAID 5 on production servers </li></ul><ul><ul><li>High aggregation transfer rates </li></ul></ul><ul><li>Backup strategies implemented both locally and at corporate levels </li></ul>
  24. 34. <ul><li>Implement Principle of Least Privilege </li></ul><ul><ul><li>Role based security </li></ul></ul><ul><ul><li>User management via groups and integrated windows security </li></ul></ul><ul><ul><li>Stored Procedures for all interactions with data </li></ul></ul><ul><ul><ul><li>Exclusion of all dynamic SQL statements </li></ul></ul></ul><ul><ul><li>Use of Certificates and Symmetric Encryption </li></ul></ul><ul><li>Additional security considerations will be included in the front end applications that interface with the data </li></ul>