Professional Documents
Culture Documents
Report
MIS602 Data Modelling and Database Design
1
Index
1. ER Diagram....................................................................................................................................2
2. Relational Model............................................................................................................................3
a. Business rules and assumptions................................................................................................3
3.Creating Tables and populating data...................................................................................................4
3.1. Contract......................................................................................................................................4
3.2. Software......................................................................................................................................4
3.3. Vendor........................................................................................................................................5
3.4 License.........................................................................................................................................6
3.5 Manager......................................................................................................................................7
3.6 Staf.............................................................................................................................................7
3.7 Devices.........................................................................................................................................8
4. Business Insights..............................................................................................................................10
4.1 SQL Query with condition..........................................................................................................10
4.2 Group by query..........................................................................................................................10
4.3 Join query..................................................................................................................................11
4.3 Nested Query.............................................................................................................................12
4.4 Cost issues.................................................................................................................................13
5. Data Visualization............................................................................................................................17
2
1. ER Diagram
3
2. Relational Model
3.2. Software
3.3. Vendor
3.4 License
CREATE TABLE license (
license_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
SKU VARCHAR(3),
contract_id VARCHAR(3),
asset_id VARCHAR(3)
);SELECT
*
FROM
license;
3.5 Manager
3.6 Staf
CREATE TABLE staf (
staf_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30),
role VARCHAR(15),
manager_id VARCHAR(3)
);
3.7 Devices
4. Business Insights
4.1 SQL Query with condition
/*
DEVICES PER EMPLOYEE
VIEW:
*/
INNER JOIN
license ON device.asset_id = license.asset_id
INNER JOIN
contract ON license.contract_id = contract.contract_id
ORDER BY `Expiry date` ASC;
select * from licenses_installed;
select
licenses_installed.device_name,
licenses_installed.license_id,
licenses_installed.`Expiry date`,
licensed_software.software_name from licenses_installed inner join licensed_software
on licensed_software.license_id = licenses_installed.license_id;
/*
NOW INCLUDING VIEW FOR SOFTWARE NAME - LICENSE
IT WILL BE USED IN THE INEER JOIN TO SHOW SOFTWARE, EXPIRY, LICENSE, DEVICE*/
The creation of views or inner join queries allow the visualization of licenses on each
device in order to be informed about the expiration date. If it is recommended to update
Windows 8 for Windows 10, it is possible to query only Windows 8 devices and order by
its expiration date, in order to prepare a schedule for the upgrading.
This same query can be organized in many ways, like device type, if we want to make the
assumption that notebooks will require Windows 8 and desktops will have Windows 10,
for a future update.
WHERE
YEAR(`Expiry date`) < 2022)
ORDER BY `Expiry date` ASC;
This query will answer which licenses are about to expire, for each software and device.
SELECT
device_type, COUNT(device_type) AS Quantity, name
FROM
device_per_staf
WHERE
device_type = 'notebook'
GROUP BY name
UNION SELECT
device_type, COUNT(device_type), name
FROM
device_per_staf
WHERE
device_type = 'netbook'
GROUP BY name
UNION SELECT
device_type, COUNT(device_type), name
FROM
device_per_staf
WHERE
device_type = 'desktop'
GROUP BY name
UNION SELECT
device_type, COUNT(device_type), name
FROM
14
device_per_staf
WHERE
device_type = 'tablet'
GROUP BY name
ORDER BY Quantity DESC;
This query allows us to find out which staf has more than one device of the same type.
In this example Willian Martins has more than one netbook, what could be a mistake or
an issue to be solved, considered a bad allocation of assets. Not only the company can
save money ensuring each staf member has one device from any kind, but also check if
they have two licenses for the same software in these devices.
In this next query, for example, the view that shows devices per employee is used. The
view was updated in order to display the type of device as well. So this next query will
demonstrate how many similar software are installed for specific members of staf . We
know already that Willian has two netbooks. He also has a desktop. It is acceptable to
have a Windows 8 for a desktop and another Windows 8 for a notebook if the employee
needs to have two devices, but it would be a duplication issue if he has two versions of
the same software for the same device, as shown below:
SELECT
name,
`software installed`,
COUNT(`software installed`) AS Quantity,
device_type
FROM
device_per_employee
WHERE
(name = 'Willian Martins'
AND device_type = 'netbook')
GROUP BY `software installed`
UNION SELECT
name,
`software installed`,
COUNT(`software installed`) AS Quantity,
device_type
FROM
device_per_employee
WHERE
(name = 'Willian Martins'
AND device_type = 'desktop')
GROUP BY `software installed`
UNION SELECT
name,
`software installed`,
15
SELECT
name, COUNT(DISTINCT device) AS Quantity
FROM
software_per_Employee
WHERE
staf_id = 1
UNION SELECT
name, COUNT(device) AS Quantity
FROM
software_per_Employee
WHERE
staf_id = 2
UNION SELECT
name, COUNT(device) AS Quantity
FROM
software_per_Employee
WHERE
staf_id = 3
UNION SELECT
name, COUNT(device) AS Quantity
FROM
software_per_Employee
WHERE
staf_id = 7;
16
5. Data Visualization
17
The information of how many software per device may demonstrate duplicated licenses, if the case.
In our example it does not occur, since ach device has one software of a kind each. However it can
also demonstrate which device has more software installed than the others, thus the need for too
many programs in a unique device could be reviewed.
It is important to have visualizations that demonstrate the need for renewal or risk of getting an
unlicensed device. In this case contract number 5 is about to expire and should be checked. In the
other hand, some upgrades may be postponed or delayed by checking log contracts as well. For
instance, a Windows 8 replacement for Windows 10 may not be recommended if the license for this
Windows 8 is going to be valid for nearly one year and is already paid for.
18
2 2 2 2 2
1
0 0
1 1
2 0
1 1 1
0 0
Willian Martins Allan Amorim Will Camara Lisa Malady
netbook notebook desktop tablet
19
The demonstration of how many software and what kind of software may lead to the information of
a company bias, and tendency that could be reviewed plus a plan for upgrading. At the same time,
some visualizations on how many netbooks, tablets or notebooks each employee has is also useful. It
is expected to have one notebook and desktop for instance, but why Willian currently holds two
devices of the same type? Why a member of the staf holds two notebooks? Is there a reason, or is
this a case of improper asset allocation? This analysis is combine with the device count visualization,
since the case of Will Camara having 4 devices could be more justified than Willian Martins having
two devices, since Will may need one device of each kind for his role. It could be an assumption that
one of Willian’s device – which is a netbook - could be allocated to Lisa, who was one device only – of
a diferent kind - in the above demonstration.