SlideShare ist ein Scribd-Unternehmen logo
1 von 49
SQL Portfolio Marcus Matthews marcusmatthews@setfocus.com http://www.linkedin.com/in/marcuswmatthews
Table of Contents Introduction			2 Jungle Books			3 Library				7 Piggy Bank			11 Block Flix 			19
Introduction This portfolio contains examples of my development skills in MS SQL Server. It is a result of my work during an 8-week hands-on experience with 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 2008 Database Designing an MS SQL Server 2008 Infrastructure Designing security for MS SQL Server 2008 Designing High Availability Database Solutions using MS SQL Server 2008 Troubleshooting and Optimizing Database Solutions using MS SQL Server 2008 SQL Server Integration Services  SQL Server reporting Services In addition to the coursework and programming labs, the program included challenging real-world projects where I have applied the skills experienced in class.
Jungle Books Jungle Books is company which uses a database to store data for books, authors, customers that purchase these items and order records. This database diagram was used to create the database and show the relationship between entities within it.  The application developer that we are working with fictitiously will use this design for a client application using .NET.
Jungle Books SELECT [o].[OrderID] AS 'Order ID' ,[o].[CustomerID] AS 'Cust ID' ,c.Name ,(SELECT SUM([oi].[QuantityOrdered])) AS '# of items' FROM [Orders] o  JOIN [OrderItems] oi ON oi.OrderID = o.OrderID JOIN Customers AS c ON c.CustomerID = o.CustomerID GROUP BY o.OrderID, o.CustomerID, c.Name Order BY (SELECT SUM([oi].[QuantityOrdered])) desc; 	The select statement for the Large Orders report is used to return orders from the Jungle Books' database that contain the highest number of items sold per order, OrderID, CustomerID, Customer Name and the items within their order. The result set is displayed in descending order listing the order with the largest quantity first.
Jungle Books 	The report named Expired Cards is a select statement used to generate a list of customers whose credit cards have expired and those that will expire within 30 days.  SELECT CustomerID AS 'ID', [Name], expiryDate AS 'Expires' FROM customers WHERE expirydate < (getDate() +30)
Library The Library Database is designed to maintain records of the day-to-day lending operations such: items available or on loan, overdue books, fees, member information, and reservations.  	This database has been used for number of projects: Create queries against the Library Database to return results using UNION and several join types. Search for book titles, by name, ISBN, and author.  Create new member accounts for juveniles and adults. Set up a reservation for an item that is currently unavailable to loan once it has been returned.
Library ER Diagram
Library SELECT lh.member_no, m.lastname, m.firstname, SUM(lh.fine_paid) AS "Fines Paid"  from loanhistlh INNER JOIN member m ON lh.member_no = m.member_no GROUP BY lh.member_no, m.lastname, m.firstname HAVING SUM(lh.fine_paid) IS NOT NULL ORDER BY SUM(lh.fine_paid) DESC, lh.member_no
Library SELECT r.isbn, t.title, m.member_no, m.lastname, 'adult' AS [member_type] FROM member m  INNER JOIN reservation r ON r.member_no = m.member_no INNER JOIN item i ON i.isbn = r.isbn INNER JOIN title t ON t.title_no = i.title_no INNER JOIN adult a ON a.member_no = m.member_no WHERE r.isbn = 288 UNION SELECT r.isbn, t.title, m.member_no, m.lastname, 'juvenile' AS [member_type] FROM member m  INNER JOIN reservation r ON r.member_no = m.member_no INNER JOIN item i ON i.isbn = r.isbn INNER JOIN title t ON t.title_no = i.title_no INNER JOIN juvenile j ON j.member_no = m.member_no WHERE r.isbn = 288 GROUP BY r.isbn, t.title, m.member_no, m.lastname ORDER BY [member_type]
Piggy Bank The Piggy Bank Database is used to simulate the daily operations of a financial institution, providing its user access to their personal information and manage accounts. This database has been used for a number of projects: Using stored procedures this database is capable of accounting for typical banking transactions, such as deposits, funds withdrawal, account transfers or if you are a new customer, create a new account.  Update account information capabilities to change an address, add another account or member to an existing account transaction history.
Piggy Bank ER Diagram
Piggy BankCreate new customer Stored procedure  SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /* written by: Marcus Matthews Date: 05/10/2010 Errors 'Last name cannot be null', 11, 1 'First name cannot be null', 11, 2 'Street cannot be null', 11, 3 'City cannot be null', 11, 4 'State cannot be null', 11, 5 'Zip code cannot be null', 11, 6 'Home Phone number cannot be null', 11, 7 */ CREATE PROCEDURE [dbo].[usp_CreateNewCustomer] @CustomerLastName nvarchar(20)=null, @CustomerFirstName nvarchar(20)=null, @CustomerMiddleName nvarchar(20)=null, @Street nvarchar(50)		=null, @City nvarchar(20)		=null,  @State nchar(2)		=null, @ZipCode nvarchar(10)	=null, @Email nvarchar(50)		=null, @HomePhone nvarchar(15)	=null, @WorkPhone nvarchar(15)	=null, @CellPhone nvarchar(15)	=null AS BEGIN TRY
Piggy BankCreate new customer Stored procedure (cont.)  -- Test parameters. All required fields must have a value, only test those that do not allow nulls If @CustomerLastName is null 	BEGIN 		RAISERROR ('Last name cannot be null', 11, 1) 	END If @CustomerFirstName is null 	BEGIN 		RAISERROR ('First name cannot be null', 11, 2) 	END If @Street is null 	BEGIN 		RAISERROR ('Street cannot be null', 11, 3) END If @City  is null 	BEGIN 		RAISERROR ('City cannot be null', 11, 4) 	END If @State is null 	BEGIN 		RAISERROR ('State cannot be null', 11, 5) 	END If @ZipCode is null 	BEGIN 		RAISERROR ('Zip code cannot be null', 11, 6) 	END
Piggy Bank Create new customer Stored procedure (cont.)  If @HomePhone is null 	BEGIN 		RAISERROR ('Home Phone number cannot be null', 11, 7) 	END --Create customer and insert data  BEGIN 	INSERT INTO dbo.Customer ( 		CustomerFirstName, 		CustomerLastName, 		CustomerMiddleName, 		Street, 		City, 		[State], 		ZipCode, 		Email,  HomePhone, 		WorkPhone,  		CellPhone  	) 	VALUES ( 		@CustomerFirstName, 		@CustomerLastName, 		@CustomerMiddleName, 		@Street, 		@City, 		@State, 		@ZipCode, 		@Email,  		@HomePhone, 		@WorkPhone,  		@CellPhone  		)
Piggy Bank Create new customer Stored procedure (cont.)  END RETURN END TRY BEGIN CATCH      -- IF @@TRANCOUNT > 0      --      ROLLBACK TRAN     DECLARE @ErrorMessage NVARCHAR(4000);     DECLARE @ErrorSeverity INT;     DECLARE @ErrorState INT;     SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(),             @ErrorState = ERROR_STATE();     RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState); END CATCH GO
Piggy BankAccount Balance Stored procedure  GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /*This stored procedure is used to return the current account balance and  last 5 transactions. Error messages for omitted data in required fields.  written by: Marcus Matthews Date: 05/15/2010 Errors 'Customer ID cannot be null', 11, 1 'Account ID cannot be null', 11, 2 'Account numbers provided do not match', 11, 3 */ CREATE PROCEDURE [dbo].[GetBalance]  @CustomerID int =null, @AccountIDint =null AS BEGIN TRY If @CustomerID is null 	BEGIN 		RAISERROR ('Customer ID cannot be null', 11, 1) 	END If @AccountID is null 	BEGIN 		RAISERROR ('Account ID cannot be null', 11, 2) 	END
Piggy BankAccount Balance Stored procedure (cont.)  -- Make sure accounts match IF EXISTS(SELECT a.AccountID FROM Account a 	JOIN CustomerAccount ca 	ON ca.AccountID = a.AccountID 	JOIN Customer c 	ON c.CustomerID = ca.CustomerID 	WHERE a.AccountID = @AccountID 	) -- Make sure accounts match IF EXISTS(SELECT a.AccountID FROM Account a 	JOIN CustomerAccount ca 	ON ca.AccountID = a.AccountID 	JOIN Customer c 	ON c.CustomerID = ca.CustomerID 	WHERE a.AccountID = @AccountID 	) -- shows current balance with last 5 transactions. BEGIN 		SELECT DISTINCT TOP(5) c.CustomerID, a.CurrentBalance, t.transactionID, t.transactionDate, t.TransactionAmount 		FROM Account a 		JOIN [Transaction] t 		ON t.AccountID = a.AccountID 		JOIN Customer c 		ON c.customerID= t.CustomerID 		WHERE a.accountID = @AccountID 		AND c.CustomerID = @CustomerID END
Piggy BankAccount Balance Stored procedure (cont.) ELSE  	BEGIN 		RAISERROR ('Account numbers provided do not match', 11, 3) 	END RETURN END TRY BEGIN CATCH     DECLARE @ErrorMessage NVARCHAR(4000);     DECLARE @ErrorSeverity INT;     DECLARE @ErrorState INT;     SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(),             @ErrorState = ERROR_STATE();     RAISERROR (@ErrorMessage,  @ErrorSeverity, @ErrorState); END CATCH GO
Brian Henry Marcus Matthews Robert Parkin BlockFlix Project
Database Design
XML Data Original XML Modified XML There were a couple issues we had to overcome to process the XML. One of the challenges of processing the XML was formatting it properly and creating a schema. Another problem we had to overcome was entering the quantity of the movie into our Inventory Table.  This was done by using a OLE DB Command Transformation and calling a proc (LoadMovieInventory) to insert records in a While Loop until it looped the appropriate amount of times.
Loading Genre Data (SSIS) Raw Data Data in the Genre Table
Load Inventory/Talent SSISAlso used SSIS to load all Base Tables
Checking Out an Online Movie Member David Smith checks out movie Dark Knight (MemberID 2, MovieID 5, InventoryID 50) Rental Transaction Tables:
Checking Out a Movie (Cont.) Current Member Queue (GetMemberQueView) When Member returns Dark Night they will receive Saving Private Ryan.
Returning a Movie David Smith (2) returns (2) the movie Dark Knight (50) Rental Transactions Showing return of Dark Knight (50) and Shipment (1) of Saving Private Ryan (20)
Returning a Movie (Cont.) Member Transaction Showing return of Dark Knight and Shipment of Saving Private Ryan
Returning a Movie (Cont.) Movie Inventory for Dark Knight Showing Available (1)
Returning a Movie (Cont.) Member Queue Remains the same… when Saving Private Ryan is returned Gold Finger will be shipped.
Returning a Movie Continued When Saving Private Ryan was returned, it was deleted from the queue.
Movies Checked Out By Store exec uspGetCheckedOutByStore 1
Available Inventory By Store exec uspGetInvByStore 1
Update Member StatususpMembershipUpgrade Pre-Update Post Update
Update Movie Queue uspUpdateMemberQue Pre-Update Judith Hayward Only has Goldfinger Post-Update Judith Hayward added FrankensteinWill not allow movie  						to be in the queue 					more than once
Monthly Member Debit/Credit uspMonthlyMemberDebit uspMonthlyMemberCredit uspGetMemberTransactions (Lookup) TransTypeID 4 is Debit TransTypeID 3 is Credit
Lost/Damage FunctionalityuspCreateLostDamagedTransaction Pre-Damage – Movie is checked out Movie Rental Transaction Damage Report – Movie is Lost/Damaged
Lost/Damage Functionality (Cont.) Member Transactions showing fine of $4.99 LostDamaged Table
Inactivate Member if Balance Over Due uspInactivateMemberIfOverdue Member’s account is over due Now the Member’s account is inactive.
Membership Report
Most Rented Movies
Lost or Damaged Movies
Most Active Customers
Most Rented Movies
Reports on the Report Server
Database Backup (Cont.)
Database Backup
Online Streaming Proposal ,[object Object]
Create Database to track usage

Weitere ähnliche Inhalte

Andere mochten auch

Losberger Palas brochure
Losberger Palas brochureLosberger Palas brochure
Losberger Palas brochure
Matthew Bates
 
2010 11 m.b.m. (computer management) sem-i and ii
2010 11 m.b.m. (computer management) sem-i and ii2010 11 m.b.m. (computer management) sem-i and ii
2010 11 m.b.m. (computer management) sem-i and ii
Hitesh Agrawal
 
Email Marketing:Today's tool for effective customer interaction
Email Marketing:Today's tool for effective customer interactionEmail Marketing:Today's tool for effective customer interaction
Email Marketing:Today's tool for effective customer interaction
Bill Powell
 
KazooCon 2014 - Ziron, SMS for voice people
KazooCon 2014 - Ziron, SMS for voice peopleKazooCon 2014 - Ziron, SMS for voice people
KazooCon 2014 - Ziron, SMS for voice people
2600Hz
 

Andere mochten auch (19)

Caminata bíbica cañaveral
Caminata bíbica cañaveralCaminata bíbica cañaveral
Caminata bíbica cañaveral
 
Lightning Talk: Ploegert, Sharewise - Crowd mit Cloud
Lightning Talk: Ploegert, Sharewise - Crowd mit CloudLightning Talk: Ploegert, Sharewise - Crowd mit Cloud
Lightning Talk: Ploegert, Sharewise - Crowd mit Cloud
 
Losberger Palas brochure
Losberger Palas brochureLosberger Palas brochure
Losberger Palas brochure
 
Guia dg2
Guia dg2Guia dg2
Guia dg2
 
Manual identidad básico
Manual identidad básicoManual identidad básico
Manual identidad básico
 
Presentación Ser Humano
Presentación Ser HumanoPresentación Ser Humano
Presentación Ser Humano
 
15 Lambda SFIC 2009
15 Lambda SFIC 200915 Lambda SFIC 2009
15 Lambda SFIC 2009
 
Hogyan használják a hazai színházak az online kommunikációs eszközöket? (2012)
Hogyan használják a hazai színházak az online kommunikációs eszközöket? (2012)Hogyan használják a hazai színházak az online kommunikációs eszközöket? (2012)
Hogyan használják a hazai színházak az online kommunikációs eszközöket? (2012)
 
2010 11 m.b.m. (computer management) sem-i and ii
2010 11 m.b.m. (computer management) sem-i and ii2010 11 m.b.m. (computer management) sem-i and ii
2010 11 m.b.m. (computer management) sem-i and ii
 
Quale smartart?
Quale smartart?Quale smartart?
Quale smartart?
 
Making Disciples of All Nations
Making Disciples of All NationsMaking Disciples of All Nations
Making Disciples of All Nations
 
MANEJO Y TRATAMIENTO DE TBC
MANEJO Y TRATAMIENTO DE TBCMANEJO Y TRATAMIENTO DE TBC
MANEJO Y TRATAMIENTO DE TBC
 
Making PCI V3.0 Business as Usual (BAU)
Making PCI V3.0 Business as Usual (BAU)Making PCI V3.0 Business as Usual (BAU)
Making PCI V3.0 Business as Usual (BAU)
 
WBDB 2015 Performance Evaluation of Spark SQL using BigBench
WBDB 2015 Performance Evaluation of Spark SQL using BigBenchWBDB 2015 Performance Evaluation of Spark SQL using BigBench
WBDB 2015 Performance Evaluation of Spark SQL using BigBench
 
Email Marketing:Today's tool for effective customer interaction
Email Marketing:Today's tool for effective customer interactionEmail Marketing:Today's tool for effective customer interaction
Email Marketing:Today's tool for effective customer interaction
 
KazooCon 2014 - Ziron, SMS for voice people
KazooCon 2014 - Ziron, SMS for voice peopleKazooCon 2014 - Ziron, SMS for voice people
KazooCon 2014 - Ziron, SMS for voice people
 
PRESENTACIÓN ECOESCUELAS IES RIBERA DEL FARDES, PURULLENA (GRANADA)
PRESENTACIÓN ECOESCUELAS IES RIBERA DEL FARDES, PURULLENA (GRANADA)PRESENTACIÓN ECOESCUELAS IES RIBERA DEL FARDES, PURULLENA (GRANADA)
PRESENTACIÓN ECOESCUELAS IES RIBERA DEL FARDES, PURULLENA (GRANADA)
 
goanimate
goanimategoanimate
goanimate
 
Italian municipal election analysis
Italian municipal election analysisItalian municipal election analysis
Italian municipal election analysis
 

Ähnlich wie Marcus Matthews

Jazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane Portfolio
Jazmine Kane Portfolio
Jazmine Kane
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar15
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar15
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfolio
geometro17
 
Porfolio of Setfocus work
Porfolio of Setfocus workPorfolio of Setfocus work
Porfolio of Setfocus work
KevinPSF
 
Performance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and ApexPerformance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and Apex
Salesforce Developers
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
Kbengt521
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
Chris Seebacher
 

Ähnlich wie Marcus Matthews (20)

My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
My Portfolio
My PortfolioMy Portfolio
My Portfolio
 
Jessica Herndon Sql Portfolio
Jessica Herndon Sql PortfolioJessica Herndon Sql Portfolio
Jessica Herndon Sql Portfolio
 
Presentation Paul
Presentation PaulPresentation Paul
Presentation Paul
 
Jazmine Kane Portfolio
Jazmine Kane PortfolioJazmine Kane Portfolio
Jazmine Kane Portfolio
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Reynaldo Fadri’S Porfolio
Reynaldo Fadri’S PorfolioReynaldo Fadri’S Porfolio
Reynaldo Fadri’S Porfolio
 
Greg Lewis SQL Portfolio
Greg Lewis SQL PortfolioGreg Lewis SQL Portfolio
Greg Lewis SQL Portfolio
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
 
Rinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat PortfolioRinkeshkumar Bhagat Portfolio
Rinkeshkumar Bhagat Portfolio
 
SQL Server 2008 Portfolio
SQL Server 2008 PortfolioSQL Server 2008 Portfolio
SQL Server 2008 Portfolio
 
Df12 Performance Tuning
Df12 Performance TuningDf12 Performance Tuning
Df12 Performance Tuning
 
SetFocus SQL Portfolio
SetFocus SQL PortfolioSetFocus SQL Portfolio
SetFocus SQL Portfolio
 
Porfolio of Setfocus work
Porfolio of Setfocus workPorfolio of Setfocus work
Porfolio of Setfocus work
 
Performance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and ApexPerformance Tuning for Visualforce and Apex
Performance Tuning for Visualforce and Apex
 
Robert Parkin Portfolio
Robert Parkin PortfolioRobert Parkin Portfolio
Robert Parkin Portfolio
 
Kevin Bengtson Portfolio
Kevin Bengtson PortfolioKevin Bengtson Portfolio
Kevin Bengtson Portfolio
 
James Colby Maddox Business Intellignece and Computer Science Portfolio
James Colby Maddox Business Intellignece and Computer Science PortfolioJames Colby Maddox Business Intellignece and Computer Science Portfolio
James Colby Maddox Business Intellignece and Computer Science Portfolio
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Dwbi Project
Dwbi ProjectDwbi Project
Dwbi Project
 

Marcus Matthews

  • 1. SQL Portfolio Marcus Matthews marcusmatthews@setfocus.com http://www.linkedin.com/in/marcuswmatthews
  • 2. Table of Contents Introduction 2 Jungle Books 3 Library 7 Piggy Bank 11 Block Flix 19
  • 3. Introduction This portfolio contains examples of my development skills in MS SQL Server. It is a result of my work during an 8-week hands-on experience with 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 2008 Database Designing an MS SQL Server 2008 Infrastructure Designing security for MS SQL Server 2008 Designing High Availability Database Solutions using MS SQL Server 2008 Troubleshooting and Optimizing Database Solutions using MS SQL Server 2008 SQL Server Integration Services SQL Server reporting Services In addition to the coursework and programming labs, the program included challenging real-world projects where I have applied the skills experienced in class.
  • 4. Jungle Books Jungle Books is company which uses a database to store data for books, authors, customers that purchase these items and order records. This database diagram was used to create the database and show the relationship between entities within it. The application developer that we are working with fictitiously will use this design for a client application using .NET.
  • 5. Jungle Books SELECT [o].[OrderID] AS 'Order ID' ,[o].[CustomerID] AS 'Cust ID' ,c.Name ,(SELECT SUM([oi].[QuantityOrdered])) AS '# of items' FROM [Orders] o JOIN [OrderItems] oi ON oi.OrderID = o.OrderID JOIN Customers AS c ON c.CustomerID = o.CustomerID GROUP BY o.OrderID, o.CustomerID, c.Name Order BY (SELECT SUM([oi].[QuantityOrdered])) desc; The select statement for the Large Orders report is used to return orders from the Jungle Books' database that contain the highest number of items sold per order, OrderID, CustomerID, Customer Name and the items within their order. The result set is displayed in descending order listing the order with the largest quantity first.
  • 6. Jungle Books The report named Expired Cards is a select statement used to generate a list of customers whose credit cards have expired and those that will expire within 30 days. SELECT CustomerID AS 'ID', [Name], expiryDate AS 'Expires' FROM customers WHERE expirydate < (getDate() +30)
  • 7. Library The Library Database is designed to maintain records of the day-to-day lending operations such: items available or on loan, overdue books, fees, member information, and reservations. This database has been used for number of projects: Create queries against the Library Database to return results using UNION and several join types. Search for book titles, by name, ISBN, and author. Create new member accounts for juveniles and adults. Set up a reservation for an item that is currently unavailable to loan once it has been returned.
  • 9. Library SELECT lh.member_no, m.lastname, m.firstname, SUM(lh.fine_paid) AS "Fines Paid" from loanhistlh INNER JOIN member m ON lh.member_no = m.member_no GROUP BY lh.member_no, m.lastname, m.firstname HAVING SUM(lh.fine_paid) IS NOT NULL ORDER BY SUM(lh.fine_paid) DESC, lh.member_no
  • 10. Library SELECT r.isbn, t.title, m.member_no, m.lastname, 'adult' AS [member_type] FROM member m INNER JOIN reservation r ON r.member_no = m.member_no INNER JOIN item i ON i.isbn = r.isbn INNER JOIN title t ON t.title_no = i.title_no INNER JOIN adult a ON a.member_no = m.member_no WHERE r.isbn = 288 UNION SELECT r.isbn, t.title, m.member_no, m.lastname, 'juvenile' AS [member_type] FROM member m INNER JOIN reservation r ON r.member_no = m.member_no INNER JOIN item i ON i.isbn = r.isbn INNER JOIN title t ON t.title_no = i.title_no INNER JOIN juvenile j ON j.member_no = m.member_no WHERE r.isbn = 288 GROUP BY r.isbn, t.title, m.member_no, m.lastname ORDER BY [member_type]
  • 11. Piggy Bank The Piggy Bank Database is used to simulate the daily operations of a financial institution, providing its user access to their personal information and manage accounts. This database has been used for a number of projects: Using stored procedures this database is capable of accounting for typical banking transactions, such as deposits, funds withdrawal, account transfers or if you are a new customer, create a new account. Update account information capabilities to change an address, add another account or member to an existing account transaction history.
  • 12. Piggy Bank ER Diagram
  • 13. Piggy BankCreate new customer Stored procedure SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /* written by: Marcus Matthews Date: 05/10/2010 Errors 'Last name cannot be null', 11, 1 'First name cannot be null', 11, 2 'Street cannot be null', 11, 3 'City cannot be null', 11, 4 'State cannot be null', 11, 5 'Zip code cannot be null', 11, 6 'Home Phone number cannot be null', 11, 7 */ CREATE PROCEDURE [dbo].[usp_CreateNewCustomer] @CustomerLastName nvarchar(20)=null, @CustomerFirstName nvarchar(20)=null, @CustomerMiddleName nvarchar(20)=null, @Street nvarchar(50) =null, @City nvarchar(20) =null, @State nchar(2) =null, @ZipCode nvarchar(10) =null, @Email nvarchar(50) =null, @HomePhone nvarchar(15) =null, @WorkPhone nvarchar(15) =null, @CellPhone nvarchar(15) =null AS BEGIN TRY
  • 14. Piggy BankCreate new customer Stored procedure (cont.) -- Test parameters. All required fields must have a value, only test those that do not allow nulls If @CustomerLastName is null BEGIN RAISERROR ('Last name cannot be null', 11, 1) END If @CustomerFirstName is null BEGIN RAISERROR ('First name cannot be null', 11, 2) END If @Street is null BEGIN RAISERROR ('Street cannot be null', 11, 3) END If @City is null BEGIN RAISERROR ('City cannot be null', 11, 4) END If @State is null BEGIN RAISERROR ('State cannot be null', 11, 5) END If @ZipCode is null BEGIN RAISERROR ('Zip code cannot be null', 11, 6) END
  • 15. Piggy Bank Create new customer Stored procedure (cont.) If @HomePhone is null BEGIN RAISERROR ('Home Phone number cannot be null', 11, 7) END --Create customer and insert data BEGIN INSERT INTO dbo.Customer ( CustomerFirstName, CustomerLastName, CustomerMiddleName, Street, City, [State], ZipCode, Email, HomePhone, WorkPhone, CellPhone ) VALUES ( @CustomerFirstName, @CustomerLastName, @CustomerMiddleName, @Street, @City, @State, @ZipCode, @Email, @HomePhone, @WorkPhone, @CellPhone )
  • 16. Piggy Bank Create new customer Stored procedure (cont.) END RETURN END TRY BEGIN CATCH -- IF @@TRANCOUNT > 0 -- ROLLBACK TRAN DECLARE @ErrorMessage NVARCHAR(4000); DECLARE @ErrorSeverity INT; DECLARE @ErrorState INT; SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState); END CATCH GO
  • 17. Piggy BankAccount Balance Stored procedure GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO /*This stored procedure is used to return the current account balance and last 5 transactions. Error messages for omitted data in required fields. written by: Marcus Matthews Date: 05/15/2010 Errors 'Customer ID cannot be null', 11, 1 'Account ID cannot be null', 11, 2 'Account numbers provided do not match', 11, 3 */ CREATE PROCEDURE [dbo].[GetBalance] @CustomerID int =null, @AccountIDint =null AS BEGIN TRY If @CustomerID is null BEGIN RAISERROR ('Customer ID cannot be null', 11, 1) END If @AccountID is null BEGIN RAISERROR ('Account ID cannot be null', 11, 2) END
  • 18. Piggy BankAccount Balance Stored procedure (cont.) -- Make sure accounts match IF EXISTS(SELECT a.AccountID FROM Account a JOIN CustomerAccount ca ON ca.AccountID = a.AccountID JOIN Customer c ON c.CustomerID = ca.CustomerID WHERE a.AccountID = @AccountID ) -- Make sure accounts match IF EXISTS(SELECT a.AccountID FROM Account a JOIN CustomerAccount ca ON ca.AccountID = a.AccountID JOIN Customer c ON c.CustomerID = ca.CustomerID WHERE a.AccountID = @AccountID ) -- shows current balance with last 5 transactions. BEGIN SELECT DISTINCT TOP(5) c.CustomerID, a.CurrentBalance, t.transactionID, t.transactionDate, t.TransactionAmount FROM Account a JOIN [Transaction] t ON t.AccountID = a.AccountID JOIN Customer c ON c.customerID= t.CustomerID WHERE a.accountID = @AccountID AND c.CustomerID = @CustomerID END
  • 19. Piggy BankAccount Balance Stored procedure (cont.) ELSE BEGIN RAISERROR ('Account numbers provided do not match', 11, 3) END RETURN END TRY BEGIN CATCH DECLARE @ErrorMessage NVARCHAR(4000); DECLARE @ErrorSeverity INT; DECLARE @ErrorState INT; SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(), @ErrorState = ERROR_STATE(); RAISERROR (@ErrorMessage, @ErrorSeverity, @ErrorState); END CATCH GO
  • 20. Brian Henry Marcus Matthews Robert Parkin BlockFlix Project
  • 22. XML Data Original XML Modified XML There were a couple issues we had to overcome to process the XML. One of the challenges of processing the XML was formatting it properly and creating a schema. Another problem we had to overcome was entering the quantity of the movie into our Inventory Table. This was done by using a OLE DB Command Transformation and calling a proc (LoadMovieInventory) to insert records in a While Loop until it looped the appropriate amount of times.
  • 23. Loading Genre Data (SSIS) Raw Data Data in the Genre Table
  • 24. Load Inventory/Talent SSISAlso used SSIS to load all Base Tables
  • 25. Checking Out an Online Movie Member David Smith checks out movie Dark Knight (MemberID 2, MovieID 5, InventoryID 50) Rental Transaction Tables:
  • 26. Checking Out a Movie (Cont.) Current Member Queue (GetMemberQueView) When Member returns Dark Night they will receive Saving Private Ryan.
  • 27. Returning a Movie David Smith (2) returns (2) the movie Dark Knight (50) Rental Transactions Showing return of Dark Knight (50) and Shipment (1) of Saving Private Ryan (20)
  • 28. Returning a Movie (Cont.) Member Transaction Showing return of Dark Knight and Shipment of Saving Private Ryan
  • 29. Returning a Movie (Cont.) Movie Inventory for Dark Knight Showing Available (1)
  • 30. Returning a Movie (Cont.) Member Queue Remains the same… when Saving Private Ryan is returned Gold Finger will be shipped.
  • 31. Returning a Movie Continued When Saving Private Ryan was returned, it was deleted from the queue.
  • 32. Movies Checked Out By Store exec uspGetCheckedOutByStore 1
  • 33. Available Inventory By Store exec uspGetInvByStore 1
  • 35. Update Movie Queue uspUpdateMemberQue Pre-Update Judith Hayward Only has Goldfinger Post-Update Judith Hayward added FrankensteinWill not allow movie to be in the queue more than once
  • 36. Monthly Member Debit/Credit uspMonthlyMemberDebit uspMonthlyMemberCredit uspGetMemberTransactions (Lookup) TransTypeID 4 is Debit TransTypeID 3 is Credit
  • 37. Lost/Damage FunctionalityuspCreateLostDamagedTransaction Pre-Damage – Movie is checked out Movie Rental Transaction Damage Report – Movie is Lost/Damaged
  • 38. Lost/Damage Functionality (Cont.) Member Transactions showing fine of $4.99 LostDamaged Table
  • 39. Inactivate Member if Balance Over Due uspInactivateMemberIfOverdue Member’s account is over due Now the Member’s account is inactive.
  • 42. Lost or Damaged Movies
  • 45. Reports on the Report Server
  • 48.
  • 49. Create Database to track usage
  • 50. Master List of Movies as only one movie is needed for download
  • 51. Possibly offer unlimited usage per month for mailing members and one time usage fees for non-members
  • 52. Possibly offer an Online Only Member Status with its own fees
  • 53.
  • 54. We have already designed and created the databases for the In-Store Retail Sales and Kiosks.
  • 55. Stored Procedures, Report Packages, SSIS Packages, Test Data are currently in the development phase.