You are on page 1of 24

Mckaylan Perumalsami

Student Number: 18003974


PATHWAY: CLDV6211
Lecturer: Mr H.C Mpofu
07 May 2019

Cloud Development POE - TASK 2


Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Contents
Introduction ................................................................................................................ 3
1. Revised Entity Relation Diagram for Task 2 ........................................................ 4
2. Table Creation in SQL SERVER.......................................................................... 5
3. Table Population in SQL SERVER ...................................................................... 6
4. Queries ................................................................................................................ 9
4.1. ALL EMPLOYEES THAT HAVE WORKED ON A JOB ................................. 9
4.2. MATERIALS USED ON EACH JOB CARD WITH FULL CONVERSION .... 10
4.3. JOB CARDS THAT CHRIS BYNE HAS WORKED ON ............................... 11
4.4. JOB CARDS THAT HAVE TAKEN PLACE IN ADDRESSES THAT
CONTAIN '0001' OR '0002' ................................................................................... 12
4.5. NUMBER OF JOB CARDS THAT HAVE USED ELECTRICAL WIRING .... 13
4.6. QUERY FOR INVOICE USE ....................................................................... 14
4.7 UPDATE Query ............................................................................................... 16
5. Data Migration ................................................................................................... 17
6. Conclusion ......................................................................................................... 23
7. References ........................................................................................................ 24

2|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Introduction
Domingo Roof Works is a small company that deals in converting rooftops and lofts
into liveable rooms or quarters. In this POE (Task 2), I will be creating a database to
store a copy of their hard copy records. I will also create relationships between the
various entities.
I have also revised the Entity Relationship Diagram from Task 1. I will be migrating
the database to an online cloud platform (MICROSOFT AZURE).

3|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

1. Revised Entity Relation Diagram for Task 2


Below is a graphical representation of how the database will be structured. It is a
revised diagram of task1. I have decided to eliminate my bridge entities between
jobs and materials. I now have a combined entity for them (JOB_MATERIALS).

I have also used a star structure to extract the primary keys from the outer tables by
using the one inner table (JOB_DETAILS). The main table has no primary keys, but
does have 4 foreign keys and lone attribute (NO_OF_DAYS).

4|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

2. Table Creation in SQL SERVER


Below is the code for the creation of all the entities and their constraints.

5|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

3. Table Population in SQL SERVER


Below is the way I populated the tables. I started populating the outside tables and
working my way into the inner table.

6|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

7|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

This is the inner table. It references all the data from the outer tables by using their
primary keys. It has four foreign key constraints that relies on the primary keys of the
other tables.

8|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4. Queries
4.1. ALL EMPLOYEES THAT HAVE WORKED ON A JOB
In this query, I have used the JOB_CARD_NO, EMPLOYEE_ID and
EMPLOYEE_NAME (FIRST_NAME + SECOND NAME).
The question needed us to show the JOB_CARD_NO that each employee has
worked on. To do this, I used the EMPLOYEE, JOB_DETAILS and
JOB_MATERIALS tables. I included a WHERE statement that merges the unique
values for JOB_CARD_NO and EMPLOYEE_ID, so it would remove any redundant
data.
CODE:

SCREENSHOT:
Below is a screenshot of the output of my query.

9|Page
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.2. MATERIALS USED ON EACH JOB CARD WITH FULL CONVERSION


In this query, I needed to select all the materials used on each JOB_CARD_NO. I
also need to display the records with a ‘Full Conversion’ Job Type. To do this, I used
the JOB_CARD_NO, STANDARD_FLOOR_BOARDS, POWER_POINTS,
STANDARD ELECTRICAL WIRING and STANDARD STAIRS PACK in my SELECT
statement.
I used the JOB_MATERIALS and JOB_DETAILS tables for the query. My WHERE
statement merges the JOB_CARD_NO from the JOB_DETAILS and the
JOB_MATERIALS tables. I have also specified that I want only the records that are
of ‘Full Conversion’ Job Types.
CODE:

SCREENSHOT:
Below is a screenshot of the output of my query.

10 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.3. JOB CARDS THAT CHRIS BYNE HAS WORKED ON


In this query, I needed to select all records that Chris Byne has worked on. I used
the JOB_CARD_NO, EMPLOYEE_ID and the EMPLOYEE_NAME (FIRST_NAME +
LAST_NAME) in my SELECT statement.
I used the JOB_DETAILS, JOB_MATERIALS and EMPLOYEE tables to extract the
records, that only Chris Byne worked on.
CODE:

SCREENSHOT:
Below is a screenshot of the output of my query.

11 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.4. JOB CARDS THAT HAVE TAKEN PLACE IN ADDRESSES THAT CONTAIN '0001'
OR '0002'
In this query, I needed to select all records that had a postal code that was equal to
‘0001’ or ‘0002’. I used the JOB_CARD_NO, CUSTOMER_ID and POSTAL_CODE
attributes in my SELECT statement.
For this query, I used the ADDRESS, CUSTOMER, JOB_DETAILS and the
JOB_MATERIALS tables.
The WHERE statement can be viewed below:
CODE:

SCREENSHOT:
Below is a screenshot of the output of my query.

12 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.5. NUMBER OF JOB CARDS THAT HAVE USED ELECTRICAL WIRING


For this query, I have used two queries. The first query selects all job cards and how
many times electrical wiring has been used. The second Query adds all the times it
has been used and displays a single value for the amount of job cards that used
them. The first query shows which job card uses the electrical wiring and how many
times it used it.
CODE:

SCREENSHOT:
Below are the screenshots of the output of my queries.

13 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.6. QUERY FOR INVOICE USE


In this query, I needed to provide an output that would revise the entire database and
show me all the records for each JOB_CARD_NO. Each line needs to represent one
record. The purpose of this query s to show an output that could be used to draw up
invoices for the business.
I used multiple SUM functions to calculate the total prices without VAT, Total price
including VAT and the actual VAT amount.
A GROUP BY statement is included at the end of the query to display the records
accordingly.
CODE:

SCREENSHOT:
Below are the screenshots of the output of my queries.
NB: The screenshots below all fit on one line, it is the combined output of
three screenshots on one query. Each row represents an invoice sample.

14 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

15 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

4.7 UPDATE Query


In this Query, I needed to update the daily rate for full conversions to R 1 440.
I used the following code to do this:
Code:

Screenshots:

16 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

5. Data Migration
At this stage, the database is complete and the queries have been executed. I
have reviewed my queries and fixed any form of errors.
The next step in this POE – TASK 2 is to migrate the database onto a cloud
platform. To accomplish this, I will be using Microsoft AZURE.
Firstly, we need to logon to the portal at https://azure.microsoft.com/en-
in/free/students/ .

The next step is to navigate over to the portal, located at the top right of the
screen.

17 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Now that we have entered the portal, locate the SQL DATABASES tab to the left
of the screen. It is in the list menu to the left of the screen.

Once you have located it, open its tab and select Create SQL Database.

Follow the on-screen steps


to create an instance of an
online cloud database in
AZURE.

18 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Now that you have followed the steps to creating an instance of an azure
database on the portal, we need to deploy the database from SQL SERVER on
the local Machine
To accomplish this, we need to connect to our database in SQL SERVER.
Navigate to the right of the window and right click on the database that we are
using. Scroll down to TASKS and select extract Data tier Application.

19 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Once the wizard Opens, click next.

The next step is to follow the on-screen prompts to save your database as a
BACPAC file on your local Disk.

20 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Click next to view your summary and to see the results at the end.

The next step is to Import a BACPAC file into SQL SERVER using an Azure
Connection.

21 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

Once it connects you can view the database and validate it to check if it is online.
In SSMS navigate to the instance of your Database.

This will let you know whether your database is online or not. You can also navigate
to the AZURE portal, as discussed previously to view the SQL DATABASES that
have been created and also to check if they are online.

22 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

6. Conclusion

At this stage, all the database objects have been migrated to the AZURE online
cloud platform and has been validated and checked that it is online. The database
works and is fully functional.

23 | P a g e
Mckaylan Perumalsami CLDV6211 – POE Task 2 Student Number: 18003974

7. References

1. Montalvao, V. (2019). Learn how to Migrate a SQL Server database to SQL Azure server.
[online] Mssqltips.com. Available at: https://www.mssqltips.com/sqlservertip/5255/learn-how-
to-migrate-a-sql-server-database-to-sql-azure-server/ [Accessed 7 May 2019].

2. Chao, L. (2014). Cloud database development and management. Boca Raton: Taylor &
Francis.

3. mobilerootindia (2016). How to Move SQL Database from Local SQL Server to Azure SQL
Server Step by Step tutorial. [video] Available at:
https://www.youtube.com/watch?v=NfTTw5JqnRk&t=20s [Accessed 7 May 2019].

4. Docs.microsoft.com. (2019). Tutorial: Use Azure Database Migration Service to migrate


offline from SQL Server to a single/pooled database in Azure SQL Database. [online]
Available at: https://docs.microsoft.com/en-us/azure/dms/tutorial-sql-server-to-azure-sql
[Accessed 7 May 2019].

5. SherWeb. (2019). Azure Data Migration - Five Ways to get your data in the cloud. [online]
Available at: https://www.sherweb.com/blog/cloud-server/azure-data-migration/ [Accessed 7
May 2019].

24 | P a g e

You might also like