SetFocus SQL Portfolio

20
SQL Portfolio Jorge I. Giraldo jorge.giraldo@setfocus .com (201) 562-2314

Transcript of SetFocus SQL Portfolio

Page 1: SetFocus SQL Portfolio

SQL Portfolio

Jorge I. Giraldojorge.giraldo@setfocus.

com(201) 562-2314

Page 2: SetFocus SQL Portfolio

Piggy Bank Project ……………………………………………………………………………………………………………p.3Piggy Bank Diagram …………………………………………………………………………………………………….…...p.4Create Deposit Stored Procedure …………………………………………………………………………………….…..p.5Create Withdrawal Stored Procedure ……………………………………………………………………………..……..p.6Update Account and Add Customer Stored Procedure …………………………………………………………..….p.7Views …………………………………………………………………………………………………………………………..p.8DDL Triggers ……………………………………………………………………………………………………………..….p. 9DBA Practicals ……………………………………………………………………………………………………………….p.10Backup of EmployeeWorkHistory file group ……………………………………………………………………..…...p.11Creating Snapshot and Reverting Database to Snapshot ……………………………………………………..

…..p.12Creating Sales Manager Role ……………………………………………………………………………………….…...p.13Configuring Distribution on the Default Instance ……………………………………………………………….....p.14SSIS/SSRS Project …………………………………………………………………………………………………….…….p.15ImportVendors Package …………………………………………………………………………………………….……p.16ImportOrders Package ……………………………………………………………………………………………….…..p.17Vendor Sales By Year Design ……………………………………………………………………………………….…..p.18Vendor Sales By Year Report ……………………………………………………………………………………….......p.19What is SetFocus …………………………………………………………………………………………………….…….p.20

Page 3: SetFocus SQL Portfolio

The focus of this project is to create a database for a bank utilizing stored procedures, functions, views, as well as DDL and DML triggers. Some of the functionalities of the database include:

- Creating and updating customer information. - Creating and updating customer accounts. - Adding a new customer to an existing account. - Performing transactions such as deposits, withdrawals and money transfers. - Charging overdraft fees as well as additional applicable fees to both Checking and Savings accounts. - Opening and closing accounts. - Applying interest rates to savings accounts. - Preventing accounts deletions. - Obtaining account history for both current month as well as any month. - Queries to search for customers by name, phone number and account

number

Page 4: SetFocus SQL Portfolio
Page 5: SetFocus SQL Portfolio

Input Parameters: @AccountID, @CustomerID, @Transaction Amount.Once the procedure checks to see if the account is active and the transaction amount is greater than 0 new values are inserted into the Transactions table and the Balance in the Accounts table is updated.

Page 6: SetFocus SQL Portfolio

Input Parameters: @AccountID, CustomerID, @TransactionAmount.This procedure validates to make sure the customer is associated with the account and to make sure the account is active. Once all the validations are checked new values are inserted into the Transactions table.

Page 7: SetFocus SQL Portfolio

Input Parameters: @AccountID, @CustomerID, @UpdateType, @NewBalance, @SpecificOverdraftAccountID, GeneralOverdraft.Output Parameters: @CustomerAccountID.Validations: 1)Do not allow for a customer to be added to an account more than once. 2) Account cannot be reopen with less than $20. 3) Account cannot be closed unless balance is $0. Inserts: CustomerAccount table.Updates: AccountStatus

Page 8: SetFocus SQL Portfolio

The vBalance view is called by the GetBalance Stored Procedure to show the current balance with the last 5 transactions. The vCustomerAccountInfo view is called by the CustomerAccountInfo stored procedure to obtain statements by either CustomerID or AccountNumber. The vTransactionsView is called by the GetTransactions stored procedure to show transactions on a particular account for the past 30 days.

Page 9: SetFocus SQL Portfolio

Use DDL triggers to prevent customer accounts and transactions from being accidently deleted.

Page 10: SetFocus SQL Portfolio

The following practical exercises will work primarily in the Adventureworks2008

Database. The main objectives are as follows: -Install and configure SQL Server 2008. -Manage database files. -Backup and restore databases (please use \\SFFILE\

USERS\). -Manage security. -Transfer data into and out of SQL Server. -Automate administrative tasks. -Replicate data between SQL Server instances. -Maintain high availability. -Monitor SQL Server.

Page 11: SetFocus SQL Portfolio

Create a new filegroup, EmployeeWorkHistoryFG, containing one file, EmpWorkHist.ndf, in the default data directory of the default SQL Server 2008 instance. The data file should have an initial size of 100MB and should not allow for autogrowth.

Page 12: SetFocus SQL Portfolio

You have been assigned the task of creating a database snapshot that will allow the database to be recovered from the database snapshot, often referred to as reverting to the database snapshot.

Page 13: SetFocus SQL Portfolio

Riley is the first employee hired that will need access to select records from all tables in the Sales schema. In the upcoming weeks, several other Sales Managers will be hired, all of which will require the same access as Riley Using the principle of least privilege, give Riley and her future colleagues the minimal permissions necessary to perform their tasks.

Page 14: SetFocus SQL Portfolio

The Adventureworks company has decided that Production.Product data should be maintained at all three locations. The headquarters office, which is the default instance, should be the publisher and distributor. SQLInstance2 and SQLInstance3 will be subscribers in a transactional replication scenario that supports immediate updating subscribers.

Page 15: SetFocus SQL Portfolio

You’ll create an SSIS project with 6 packages – most of them will import data from CSV files into a new database that you’ll create

You’ll create an SSRS project with 2 reports, and you’ll schedule one of them for a report snapshot and subscription

At the end, you’ll email your database backup and SSIS packages and SSRS reports to the email address [email protected]

Page 16: SetFocus SQL Portfolio

Add tasks to the package to import the contents of the CSV file VendorMaster.CSV into the Vendor table in MiniAdventureWorksDB. Write the package so that any input row with a VendorNumber that is not found in the Vendor table will be inserted.Write the package so that any input row with a Vendor number that IS found in the Vendor table will be updated, but only if any of the other columns have changed.

Page 17: SetFocus SQL Portfolio

Add tasks to the package to import the contents of each CSV file with the base name of PODATA_*.CSV into the PurchaseOrderHeader and PurchaseOrderDetail tables in MiniAdventureWorksDB.Loop through all files with the name of PODATA_*.CSVAs you process files, move them to the folder C:\SQLProjectOutputFiles\PROCESSED (create the folder if it does not exist), so that they are not processed a 2nd time

Page 18: SetFocus SQL Portfolio

Parameters: ShipMethod (user can select 1 or more Ship Method Names).Report annotations: Show the Ship Method Name(s) selected, the report title (“Vendor Sales by Year”), the date/time executed, the user who run the report, and the Page X of Y annotation.Report should show 1 line for each Vendor, along with sales for each year (hint: in the query, summarize TotalDue and group by the year of OrderDate).

Page 19: SetFocus SQL Portfolio
Page 20: SetFocus SQL Portfolio

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.