CROWN DATA ANALYSIS AND CONSULTANCY LIMITED
FINANCE SYSTEM DATABASE
By: CODA ANALYTICS
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Agenda
1 | DSU |
2 | Overview |
3 | Business Use case |
4 | Quick Data Overview |
5 | Database Requirements |
6 | Normalization |
7. | Database Creation |
8. | Testing |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Business Use Case
What's the use case? | A storage platform that tracks the CODA Cash inflow,Cash Outflow which will be used to develop reports in Tableau. |
Who has interest in this information | This platform and it’s data will be of importance to CODA management |
How should the information be presented to users | An SQL database will be developed which a user can interact with |
Why should this use case be of interest to users | This will enable identification and remedy of expenditure on non performing areas |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Transaction Data Overview
Dimensions | Facts |
Sender | Phone |
category | transaction_date |
sub_category | amount |
receiver | qty |
Department | |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Transaction Data Sample
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PAYMENT_HISTORY Data Overview
Dimensions | Facts |
Customer | payment_fees |
fee balance | |
payment_method | contract_submitted_date |
| phone |
| |
| |
| |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PAYMENT_HISTORY Data Sample
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DATABASE
Transaction DATABASE DEVELOPMENT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Requirements
As a…...... | I Want to….... | So I can…..... |
Business User | normalize finance transaction dataset into the following tables: Senders_tbl, Receiver_tbl,Department_tbl,categories_tbl,Subcategories_tbl,TransactionsFCT_tbl | Optimize the database to eliminate data redundancy |
Business user | I want to create a data dictionary with the following columns:Database,Tables,Column Name,Example,Data types,Character length or size,Null or Not Null,Description(Primary or foreign key) | So that we can store data and will also guide during creation of tables in sql |
| |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Data Normalization
Data Normalization is the process of organizing data to achieve the following goals
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Normalization Process
1 | Separate facts from dimensions in the dataset facts – These are quantitative values that can be subjected to mathematical operations Dimensions – These are qualitative values and they are just identifiers |
2 | There should be no repetition in the table If there is repetition, you must move the column(s) to a new table without repetition |
3 | Values in a column must be singular/atomic if the values are not singular, then you must create another column within the same table to separate those values |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Normalization Process
4 | Introduce unique identifiers (Primary Key) for each row if a table does not have a primary key column, give it one Primary Keys should never contain sensitive information e.g. bank account number All the columns must not depend on each other but the primary key of the table |
5 | Introduce foreign keys when you have more than one table Foreign Key is a column that is a primary key in another table and is used to link the two tables We use the hierarchical (child, mother, …) concept in applying the foreign keys i.e. the primary key in the child table becomes the foreign key in the mother table |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Sample Normalized Table
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Sample Data Dictionary
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Transaction DATABASE
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Transaction Database Testing
Test Description | Test Steps |
To validate that the Transaction data has been organized into the following tables, Employee_tbl,Platform_tbl,Fct_tbl, | 1.Open the Normalized Data for whatsapp 2. Check the available various sheets names 3. Identify that there exists dimensions and facts sheets
4. Check that there exists Fct_Tbl, Dim_Employee_Tbl and Dim_Platform_Tbl |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Transation DB Test validations
|
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DATABASE
PAYMENT_HISTORY DATABASE EVELOPMENT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
As a…...... | I Want to….... | So I can…..... |
Business User | normalize finance_payment_history dataset into the following tables: fct_tbl, officelocation_tbl, | Optimize the database and eliminate data redundancy |
Business user | I want to create a data dictionary with the following columns:Database,Tables,Column Name,Example,Data types,Character length or size,Null or Not Null,Description(Primary or foreign key) | use it as a reference while developing the tables in SQL server |
| |
Requirements
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PAYMENT_HISTORY DATABASE
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PAYMENT_HISTORY DBA Testing
Test Description | Test Steps |
To validate that the meetings data has been organized into fct_tbl, Particpant_position_tbl, meeting type_tbl, officelocation_tbl, meeting topic_tbl | 1.Open the Normalized Data for meetings 2. Check the available various sheets names 3. Identify that there exists dimensions and facts sheets
4. Check that there exists fct_tbl, Particpant_position_tbl, meeting type_tbl, officelocation_tbl, meeting topic_tbl |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PAYMENT_HISTORY DBA Test validations
|
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DATABASE
CUSTOMERUSER DATABASE DEVELOPMENT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CUSTOMERUSER Data Overview
Dimensions | Facts |
firstname | id |
lastname | phone |
is_staff | |
is_client | |
gender | |
| |
| |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CUSTOMERUSER Data Sample
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CUSTOMERUSER DATABASE
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CUSTOMERUSER DBA Testing
Test Description | Test Steps |
To validate that DAF dataset have been organized in the following tables Fct_tbl, Department_tbl,Employee_tbl,Task_tbl,Subtask_task | 1. Open the DAF records normalization file 2. Identify the sheets denoted by various table names 3. On the sheets identified are Fct_tbl |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CUSTOMERUSER DBA Test validations
|
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
RESEARCH
Category | Description | Link |
First Normal form | Describes how to eliminate repetition | |
First Normal form | Atomicity | |
2ND Normal Form | Eliminates partial dependencies in the tables | |
Third Normal Form | getting rid of transitive dependency |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Key
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Repetiton | Explain why repetition is allowed in some cases where you cant get rid of them since they are meaning full | |
| | |
| | |
| | |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
AGENDA
1 | DSU |
2. | Basic queries For Retrieving Data |
3. | Joins |
4. | Store procedure and its importance |
5. | Views and its importance |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Business Use Case
What's the use case? | A storage platform that tracks the CODA Cash inflow,Cash Outflow which will be used to develop reports in Tableau. |
Who has interest in this information | This platform and it’s data will be of importance to CODA management |
How should the information be presented to users | An SQL database will be developed which a user can interact with |
Why should this use case be of interest to users | This will enable identification and remedy of expenditure on non performing areas |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Basic querries
Learning objectives
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Select statement
Use SELECT Command for Retrieving data from a table
SELECT [Date]
FROM TransactionFCT_tbl;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
If we want more information, we can just add a new column to the list of fields, right after SELECT:
SELECT [Date],Quantity,[amount(ksh)]
FROM TransactionFCT_tbl;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT DISTINCT
If we want only the unique values so that we can quickly see what species have been sampled we use DISTINCT
SELECT DISTINCT department_ID, [Date],Quantity,[amount]
FROM TransactionFCT_tbl;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
FILTERING
Databases can also filter data – selecting only the data meeting certain criteria
We need to add a WHERE clause to our query:
SELECT*
FROM TransactionFCT_tbl
WHERE Department_ID='2001';
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Use of WHERE & AND clause
We can use more sophisticated conditions by combining tests with AND and OR.
AND is an operator that combines two conditions. Both conditions must be true for the row to be included in the result set
SELECT*
FROM [PaymenthistFCT_tbl]
WHERE (Department_ID='2001') AND Balance>'600');
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Filter
We can use more sophisticated conditions by combining tests with AND and OR.
SELECT*
FROM [PaymenthistFCT_tbl]
WHERE (Department_ID='2001') OR ([Balance]>'600');
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SORTING
We can also sort the results of our queries by using ORDER BY
The keyword ASC tells us to order it in Ascending order. We could alternately use DESC to get descending order.
SELECT *
FROM Fct_Cost_tbl
ORDER BY [Amount(Ksh)] ASC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
sorting cont’d
We can also sort on several fields at once.
SELECT [Date],Quantity,[amount]
FROM TransactionFCT_tbl
WHERE (amount]>'600')
ORDER BY department_IDASC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT column_name
FROM table_name
ORDER BY column_name ASC | DESC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
The computer is basically doing this:
Clauses are written in a fixed order: SELECT, FROM, WHERE, then ORDER BY. It is possible to write a query as a single line, but for readability, we recommend to put each clause on its own line.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
ALTERING TABLE
Once a table is created in the database, there are many occasions where one may wish to change the structure of the table. In general, the SQL syntax for ALTER TABLE is,
ALTER TABLE TransactionFCT_tbl ADD ‘USD’ MONEY
SELECT * FROM TransactionFCT_tbl
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
UPDATING TABLE
UPDATE TransactionFCT_tbl
SET [Date] = '6/7/2024'
WHERE department_ID= 2001
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
1. WHERE
Example: To find transactions where the amount is greater than 1000:�sql�CopyEdit�SELECT * FROM cashoutflow_tbl WHERE amount > 1000;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
. BETWEEN
Example: To find cash inflow payments made between two dates:�sql�CopyEdit�SELECT * FROM cashinflow_tbl
WHERE rep_date BETWEEN '2023-01-01' AND '2023-12-31';
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
3. AND
Example: To find transactions sent by a specific sender (sender_id = 1) and for a specific department (department_id = 2):�sql�CopyEdit�SELECT * FROM cashoutflow_tbl
WHERE sender_id = 1 AND department_id = 2;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
4. OR
Example: To find transactions where the department is 1 or 2:�sql�CopyEdit�SELECT * FROM cashoutflow_tbl
WHERE department_id = 1 OR department_id = 2;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
GROUP BY
Example: To calculate the total transaction cost for each department:�sql�CopyEdit�SELECT department_id, SUM(transaction_cost) AS total_cost
FROM cashoutflow_tbl
GROUP BY department_id;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
6. SUM
Example: To calculate the total amount of all cash inflow payments:�sql�CopyEdit�SELECT SUM(amount) AS total_amount FROM cashoutflow_tbl;
To retrieve the total amount, average transaction cost, and count of transactions for each department, ordered by the total amount (highest to lowest):
sql
CopyEdit
SELECT department_id,
SUM(amount) AS total_amount,
AVG(transaction_cost) AS avg_cost,
COUNT(*) AS transaction_count
FROM cashoutflow_tbl
GROUP BY department_id
ORDER BY total_amount DESC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
7. MAX
Example: To find the maximum payment fees:�sql�CopyEdit�SELECT MAX(payment_fees) AS max_fees FROM cashinflow_tbl;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
8. COUNT
Example: To count the number of transactions in a specific department:�sql�CopyEdit�SELECT COUNT(*) AS transaction_count
FROM cashoutflow_tbl
WHERE department_id = 3;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
9. AVG
Example: To find the average amount of cash outflow transactions:�sql�CopyEdit�SELECT AVG(amount) AS avg_amount FROM cashoutflow_tbl;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
10. ORDER BY
Example: To retrieve transactions ordered by transaction date in descending order:�sql�CopyEdit�SELECT * FROM cashoutflow_tbl
ORDER BY transaction_date DESC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Combined Example Query
To retrieve the total amount, average transaction cost, and count of transactions for each department, ordered by the total amount (highest to lowest):
sql
CopyEdit
SELECT department_id,
SUM(amount) AS total_amount,
AVG(transaction_cost) AS avg_cost,
COUNT(*) AS transaction_count
FROM cashoutflow_tbl
GROUP BY department_id
ORDER BY total_amount DESC;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
The GROUP BY clause is used to tell SQL what level of granularity the aggregate function should be calculated in. The level of granularity is represented by the columns in the SELECT statement that are not aggregate functions.
below is the syntax for group by;
SELECT "column_name1", "function type" ("column_name2")
FROM "table_name"
GROUP BY "column_name1";
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SQL FUNCTIONS
Since we have started dealing with numbers, the next natural question to ask is if it is possible to do math on those numbers, such as summing them up or taking their average. The answer is yes! SQL has several arithematic functions, and they are:
Average, sum,maximum,minimum.count,round
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
FINCTIONS
Average of the column. | |
Number of records/rows | |
MAX | Maximum of the column |
MIN | Minimum of the column. |
SUM | Sum of the column |
ROUND | Round a number to s specified precision |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SUM
select OfficelocationID, [Date],sum ([Amount(Ksh)]) as amount
from TransactionFCT_tbl
group by deparment_ID, [Date]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
AVG
select avg ([Amount(Ksh)]) as amount
from TransactionFCT_tbl
COUNT
select count ([Amount(Ksh)]) as amount
from TransactionFCT_tbl
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
MAX
select MAX ([Amount(Ksh)]) as amount
from TransactionFCT_tbl
MIN
select MIN ([Amount(Ksh)]) as amount
from TransactionFCT_tbl
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
ROUND
SELECT ROUND ([Amount(Ksh)], 2) Amount FROM TransactionFCT_tbl
WHERE department_ID= 2001
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Joins
Joins in SQL server are used to query (retrieve) data from 2 or more related tables. In general tables are related to each other using foreign key constraints
In SQL server, there are different types of JOINS.
1. CROSS JOIN
2. INNER JOIN
3. OUTER JOIN
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
General Formula for Joins
SELECT ColumnList
FROM LeftTableName
JOIN_TYPE RightTableName
ON JoinCondition
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
JOINS
Inner Join | Returns only the matching row from two tables |
left join | Returns only the matching row from two tables and non matching rows from left table |
right join | Returns only the matching row from two tables and non matching rows from right table |
full join | returns all the rows from both tables including the non matching |
Cross join | Returns the cartesian product from the tables involved |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT category,DepartmentID, Department
Department
FROM Dim_Category_tbl
JOIN Dim_Department_tbl
ON Dim_Category_tbl. CategoryID=Dim_Department_tbl.CategoryID
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT
Sender_ID AS [Sender],
Subcategory AS Subcategory,
Category,
Department AS Officelocation,
[Date],
[quantity],
[Amount] AS [Unit price(ksh)],
[Amount] AS [Amount(Ksh)]
FROM
dbo.TransactionFCT_tbl AS Trans
RIGHT JOIN
dbo.Subcategory_tbl AS Subcat
ON Trans.Sender_ID = Subcat.subcategory_ID
RIGHT JOIN
dbo.Categories_tbl AS Cat
ON Cat.category_ID = Subcat.category_ID
RIGHT JOIN
dbo.Department_tbl AS Dept
ON Dept.department_ID = Trans.department_ID
RIGHT JOIN
dbo.PaymenthistFCT_tbl AS PayHist
ON PayHist.department_ID = Dept.department_ID;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT
TransactionFCT_tbl.transaction_ID AS [Transaction ID],
TransactionFCT_tbl.Date AS [Transaction Date],
TransactionFCT_tbl.quantity AS [Quantity],
TransactionFCT_tbl.amount AS [Amount],
TransactionFCT_tbl.total AS [Total Amount],
CategoriesDim_tbl.category AS [Category],
SubcategoryDim_tbl.subcategory AS [Subcategory]
FROM
FINANCE_SYSTEM_DBA.TransactionFCT_tbl AS TransactionFCT_tbl
INNER JOIN
FINANCE_SYSTEM_DBA.CategoriesDim_tbl AS CategoriesDim_tbl
ON TransactionFCT_tbl.category_ID = CategoriesDim_tbl.category_ID
INNER JOIN
FINANCE_SYSTEM_DBA.SubcategoryDim_tbl AS SubcategoryDim_tbl
ON TransactionFCT_tbl.subcategory_ID = SubcategoryDim_tbl.subcategory_ID;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Procedure
selecting the relevant columns from the data
Eliminating repetition from the data using unique tool
Introducing an ID column to populate the ID COLUMN with values.
Joining more than one table to create the foreign key relationship among them.
Separating the tables by selecting specific columns for specific tables
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Preview
1 | DSU |
2. | Views and its importance |
3. | Review of Stored procedure |
4. | using database power the tableau |
| |
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
VIEWS
A view is nothing more than a saved SQL query. A view can also be considered as a virtual table
CREATE VIEW vw_DepartmentTransactionCost AS
SELECT COF.department_id, DEP.department_name, SUM(COF.transaction_cost) AS total_cost
FROM finance_db.fct_cashoutflow_tbl COF
JOIN finance_db.dm_department_tbl DEP ON COF.department_id = DEP.department_id
GROUP BY COF.department_id, DEP.department_name;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SELECT * from vw_DepartmentTransactionCost;
DELETE vw_DepartmentTransactionCost;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Example
CREATE VIEW vwPaymentDetailsWithUser AS
SELECT CIF.payment_id, CIF.payment_fees, CIF.down_payment, USR.first_name, USR.last_name, USR.user_category
FROM finance_db.fct_cashinflow_tbl CIF
JOIN finance_db.dm_user_tbl USR ON CIF.user_id = USR.user_id;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Advanatages of views
Advantages of using views:
1. Views can be used to reduce the complexity of the database schema,
2. Views can be used as a mechanism to implement row and column level security.
Row Level Security:
3. Views can be used to present aggregated data and hide detailed data.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Example with column level security
CREATE VIEW vw_UserTransactionInfo AS
SELECT
USR.first_name,
USR.last_name,
USR.user_category,
COF.transaction_id,
COF.receiver_name,
COF.amount,
COF.transaction_date
FROM
finance_db.dm_user_tbl USR
JOIN
finance_db.fct_cashoutflow_tbl COF
ON
USR.user_id = COF.sender_id;
select* from vWcategorybydepartmentoperation
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Example with Row level security
CREATE VIEW RecentTransactions AS
SELECT transaction_id, sender_id, receiver_name, amount
FROM finance_db.fct_cashoutflow_tbl
WHERE transaction_date > '2023-01-01';
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
SAMPLE TABLEAU REPORT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Views can be used to reduce the complexity of the database schema,Creating tables with specific columns to be used in making the reports in tableau
Sections from the Report:
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CREATE VIEW vw_FinancialDashboard AS
SELECT
L.location,
D.department_name,
C.type AS CategoryType,
MONTH(CF.transaction_date) AS MonthNumber,
DATENAME(MONTH, CF.transaction_date) AS MonthName,
CF.amount,
CF.transaction_cost
FROM
finance_db.dbo.fct_cashoutflow_tbl CF
JOIN
finance_db.dbo.dm_location_tbl L ON CF.location_id = L.location_id
JOIN
finance_db.dbo.dm_department_tbl D ON CF.department_id = D.department_id
JOIN
finance_db.dbo.dm_cashoutflow_category_tbl C ON CF.category_id = C.category_id;
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
STORE PROCEDURE
A stored procedure is group of T-SQL (Transact SQL) statements. If you have a situation, where you write the same query over and over again, you can save that specific query as a stored procedure and call it just by it's name
We will learn how to create, execute, change and delete stored procedures.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creating store proc
Create Procedure spName of procedure
as
Begin
Select column list from tblName
End
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Example
CREATE PROC spcategory
AS
BEGIN
SELECT CategoryID,category FROM Dim_Category_tbl
END
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Executing SP
EXEC spName of procedure
OR
EXECUTE spName of procedure
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Modifying SP
Alter spName of procedure
as
Begin
Select column list from tblName
End
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Deleting SP
To delete the SP,
use DROP PROC 'SPName' or DROP PROCEDURE 'SPName'
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
: All parameter and variable names in SQL server, need to have the @symbol
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
store proc with input parameter
CREATE PROC spcategorybycategoryandcategoryID
@CategoryID INT,
@category VARCHAR(100)
AS
BEGIN
SELECT CategoryID,category FROM Dim_Category_tbl WHERE CategoryID=@CategoryID and category=@category
END
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creating store proc with multuple tables
create procedure spalltables
as
begin
select [Description],Subcategory,category,Officelocation, [Date] ,Quantity,[Unit price(ksh)],[Amount(Ksh)]
from Dim_Description_tbl
right join Dim_Subcategory_tbl
ON Dim_Description_tbl.DescriptionID=Dim_Subcategory_tbl .DescriptionID
right join Dim_Category_tbl
ON
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Dim_Category_tbl.SubcategoryID=Dim_Subcategory_tbl.SubcategoryID
right join Dim_Department_tbl
on Dim_Department_tbl.CategoryID=Dim_Category_tbl.CategoryID
right join Dim_OfficeLocation_tbl
on Dim_OfficeLocation_tbl.DepartmentID=Dim_Department_tbl.DepartmentID
right join Fct_Cost_tbl
on Fct_Cost_tbl.OfficelocationID=Dim_OfficeLocation_tbl.OfficelocationID
end
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Executing store procedure
spcategorybycategoryandcategoryID 3001,'transport'
How to view the text of your store procedure
sp_helptext spcategorybycategoryandcategoryID
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Advantages of store procedure
The following advantages of using Stored Procedures over adhoc queries (inline SQL)
1. Execution plan retention and reusability - Stored Procedures are compiled and their execution plan is cached and used again, when the same SP is executed again.
2. Reduces network traffic - You only need to send, EXECUTE SP_Name statement, over the network, instead of the entire batch of adhoc SQL code.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
3. Code reusability and better maintainability - A stored procedure can be reused with multiple applications. If the logic has to change, we only have one place to change,
4. Better Security - A database user can be granted access to an SP and prevent them from executing direct "select" statements against a table. This is fine grain access control which will help control what data a user has access to.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
GOAL OF THE PROJECT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Requirement
As a CODA management i want to have CODA FINANCE DATABASE tables combined into one table with the following fields,Description from Dim_Description_tbl ,[Office Location]from Dim_officelocation_tbl , [Department] from Dim_Department_tbl,[Cost Category]from Dim_Cost category_tbl,[Cost Subcategory] from Dim_Cost Subcategory_tbl,[Quantity], [Unit Price(Ksh)],[Amount(Ksh)] [Date] from fct_Cost_tbl So that we can power the CODA FINANCE REPORT
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creating views with multiple tables
create view vWalltables
as
select [Description],Subcategory,category,Officelocation, [Date] ,Quantity,[Unit price(ksh)],[Amount(Ksh)]
from Dim_Description_tbl
right join Dim_Subcategory_tbl
ON Dim_Description_tbl.DescriptionID=Dim_Subcategory_tbl .DescriptionID
right join Dim_Category_tbl
ON Dim_Category_tbl.SubcategoryID=Dim_Subcategory_tbl.SubcategoryID
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
right join Dim_Department_tbl
on Dim_Department_tbl.CategoryID=Dim_Category_tbl.CategoryID
right join Dim_OfficeLocation_tbl
on Dim_OfficeLocation_tbl.DepartmentID=Dim_Department_tbl.DepartmentID
right join Fct_Cost_tbl
on Fct_Cost_tbl.OfficelocationID=Dim_OfficeLocation_tbl.OfficelocationID
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
splitting dating column to month and year
select datepart(Month,[Date]) Mnth,datename(Year,[Date]) [Year] from [dbo].[Fct_Cost_tbl]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Requirement As a
As a business user i would like to denomalize finance information from separate tables into one combined table with the following columns : [Description],[Cost Subcategory],[Cost Category],[Department],[Office Location],[Month],[Year] , [Date] ,[Quantity],[Unit Price(Ksh)],[Amount(Ksh)] so that i can connect the data to the tableau report.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Now, we will start by joining all the columns that we want to retrieve in our original dataset.
We will use full join to join and retrieve all the information as our dataset is.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
join
select [Description],[Cost Subcategory],[Cost Category],[Department],[Office Location], datename(Month,[Date]) [Month],datename(Year,[Date]) [Year] , [Date] ,[Quantity],[Unit Price(Ksh)],[Amount(Ksh)]
from [Dim_Description_tbl]
left join [Dim_Subcategory_tbl]
ON [Dim_Description_tbl] .[DescriptionID]=[Dim_Subcategory_tbl].[DescriptionID]
left join[Dim_Category_tbl]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
join
ON [Dim_Category_tbl].[SubcategoryID]=[Dim_Subcategory_tbl].[SubcategoryID]
left join [Dim_Department_tbl]
on [Dim_Department_tbl].[CategoryID]=[Dim_Category_tbl].[CategoryID]
left join [dbo].[Dim_OfficeLocation_tbl]
on [Dim_OfficeLocation_tbl].[DepartmentID]=[Dim_Department_tbl].[DepartmentID]
left join [dbo].[Fct_Cost_tbl]
on [Dim_OfficeLocation_tbl].[OfficeLocationID]=[Fct_Cost_tbl].[OfficeLocationID] and [Dim_Description_tbl].[DescriptionID] =[Fct_Cost_tbl].[DescriptionID]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Store procedure
After joining all our data to the desired columns, we will store the information using the store procedure
What is a store procedure?
A stored procedure is group of T-SQL (Transact SQL) statements. If you have a situation, where you write the same query over and over again, you can save that specific query as a stored procedure and call it just by it's name
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
W e will use the store procedure created to connect our data to tableau since it is carrying the same information as our Coda Finance Report
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Work completed so far
Normalization
Creation of tables and inserting of records
Basic queries
Function
Joins
Views and Importance of views
Prcedures and its advantages
Connecting the database to tableau
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Work completed so far
Below is the Link to the Query for Creation, Insertion of Records, Joints & Store Procedure for denormalizing tables and views for retrieving records using where and order by statements.
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creation Of Tables
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creation Of Tables Cont’d
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Creation Of Tables Cont’d
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Insertion
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
Insertion Cond’t
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DENORMALIZING [CODA_FINANCEDB]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DENORMALIZING [CODA_FINANCEDB]
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
CREATING VIEW
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DEMOSTRATION OF THIRD NORMAL FORM
(How to rule out transient dependencies)
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DEMOSTRATION OF THE NORMALISATION ABOVE
Demonstration of normalization
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
TABLE RELATIONSHIPS
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DIAGRAM
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
PROTOTYPE(TABLES & DATA DICTIONARY)
Click here for
Detailed view of tables and data dictionary
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
REASECH
Click here for
Detailed view of the research
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com
DESIGN
TEXT FORMART
SQL FORMART
This presentation uses a free template provided by FPPT.com
www.free-power-point-templates.com