0% found this document useful (0 votes)
327 views

Database Case Study Report

The document provides details about creating and populating tables in a SQL database to model software licensing within an organization. It includes business rules, an ER diagram, descriptions of the tables created (Software, Contract, Vendor, License, Manager, Staff, Devices), sample data inserted, and example SQL queries including a SELECT query with a condition, a GROUP BY query, a JOIN query, and a nested query. The tables are used to track software licenses, contracts, vendors, assigned devices and their relationships to provide insights into software asset management.

Uploaded by

Gabriel Zuanetti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
327 views

Database Case Study Report

The document provides details about creating and populating tables in a SQL database to model software licensing within an organization. It includes business rules, an ER diagram, descriptions of the tables created (Software, Contract, Vendor, License, Manager, Staff, Devices), sample data inserted, and example SQL queries including a SELECT query with a condition, a GROUP BY query, a JOIN query, and a nested query. The tables are used to track software licenses, contracts, vendors, assigned devices and their relationships to provide insights into software asset management.

Uploaded by

Gabriel Zuanetti
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

DATABASE CASE STUDY

REPORT
MIS602 Data Modelling and Database Design

Torrens University Australia


Summary
Business rules and assumptions...................................................................................................2
ER diagram...................................................................................................................................3
Relational Model..........................................................................................................................4
Creating tables and adding data...................................................................................................5
Software...................................................................................................................................5
Contract...................................................................................................................................5
Vendor......................................................................................................................................5
License......................................................................................................................................6
Manager...................................................................................................................................6
Staff..........................................................................................................................................6
Devices.....................................................................................................................................6
SQL Query to Business Insights....................................................................................................8
SELECT Query with condition...................................................................................................8
Group by query........................................................................................................................9
Join Query..............................................................................................................................10
Nested Query.........................................................................................................................11
Data Visualization.......................................................................................................................12
Business rules and assumptions
 Contracts have a one-year term.
 All software requires a license for each device it is installed on. Consumption licenses,
such as pay-per-gigabyte or pay-per-click, are not available. The corporation can
employ a variety of devices, including PCs and laptops, to run subscription software.
 Each employee can have multiple devices assigned to them, such as a desktop
computer and a work laptop.
 Every manager in charge of a staff member is liable for the software license placed in
that staff member.
 Every piece of software must be recognized by a unique number known as a Stock
Keeping Unit (SKU). Every device owned by the corporation should be granted a
corporate Asset ID.
 Multiple software titles from the same vendor are permitted under the same contract.
 Different contracts can exist for the same software.
 A database for IT assets will be used to check and monitor each manager's obligation
for the licensing costs of business-owned devices assigned to company employees.
 All subscriptions are paid on a month-to-month basis. There are no licenses for
consumption.
ER diagram
Relational Model
Creating tables and adding data
Software
CREATE TABLE Software (SKU INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
Software_name VARCHAR(30) NOT NULL );
alter table software add column vendor_name varchar(30), add column contract_number
varchar(30);
ALTER TABLE software RENAME COLUMN vendor_name TO vendor_id;
insert into software (SKU, Software_name, Vendor_name) values (01,"Snagit", "01");
insert into software values (02,"Photoshop", "02");
insert into software values (03,"Autocad", "03");
insert into software values (04,"Database11g", "04");
insert into software values (05,"Database12c", "04");
insert into software values (06,"Windows8", "05");
insert into software values (07,"Windows10", "05");
insert into software values (08,"Office2016", "05");
insert into software values (09,"Lightroom", "02");
insert into software values (10,"Antivirus", "06");
insert into software values (11,"Financials", "07");
insert into software values (12,"Beyond Compare", "08");
insert into software values (13,"Linux 5.0", "09");
insert into software values (14,"BRIEF", "10");

Contract
CREATE TABLE Contract ( Contract_ID INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY );
insert into contract values (01);
insert into contract values (02);
insert into contract values (03);
insert into contract values (04);
ALTER Table contract add column `Expiry date` date;
insert into contract (contract_id,`expiry date`) values (05,"2023-08-11");
UPDATE contract SET `expiry date` = '2022-11-26' WHERE contract_id = 4;
UPDATE contract SET `expiry date` = '2023-03-25' WHERE contract_id = 3;
UPDATE contract SET `expiry date` = '2023-06-25' WHERE contract_id = 2;
UPDATE contract SET `expiry date` = '2022-12-28' WHERE contract_id = 1;

Vendor
CREATE TABLE vendor ( vendor_name VARCHAR(30) NOT NULL );
alter table vendor add column vendor_id varchar (3);
insert into vendor (vendor_name, vendor_id) values ("Techsmith",01);
insert into vendor (vendor_name, vendor_id) values ("Adobe",02);
insert into vendor (vendor_name, vendor_id) values ("Autodesk",03);
insert into vendor (vendor_name, vendor_id) values ("Oracle",04);
insert into vendor (vendor_name, vendor_id) values ("Microsoft",05);
insert into vendor (vendor_name, vendor_id) values ("Kasperski",06);
insert into vendor (vendor_name, vendor_id) values ("SAP",07);
insert into vendor (vendor_name, vendor_id) values ("Scooter Software",08);
insert into vendor (vendor_name, vendor_id) values ("Rehat",09);
insert into vendor (vendor_name, vendor_id) values ("Underware",10);

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;
/* contract 1, techsmith, snaig, device 1 and 2 */
insert into license (license_id, SKU,contract_id,asset_id) values (01,01,"01",01);
insert into license (license_id, SKU,contract_id,asset_id) values (02,01,"01",02);
/* contract 2, adobe, photshop, device 1 and 2 */
insert into license (license_id, SKU,contract_id,asset_id) values (03,02,02,02);
UPDATE license SET asset_id = 01 WHERE license_id = 03;
insert into license (license_id, SKU,contract_id,asset_id) values (04,02,02,02);
/* contract 3, adobe, lightroom, device 1 and 2 */
insert into license (license_id, SKU,contract_id,asset_id) values (05,02,09,01);
insert into license (license_id, SKU,contract_id,asset_id) values (06,02,09,02);
/* contract 3, microsoft, windows 8 device 1,2,3,4 + windows 10 device 5,6 */
insert into license (license_id, SKU,contract_id,asset_id) values (07,03,06,01);
insert into license (license_id, SKU,contract_id,asset_id) values (08,03,06,02);
insert into license (license_id, SKU,contract_id,asset_id) values (09,03,06,03);
insert into license (license_id, SKU,contract_id,asset_id) values (10,03,06,04);
insert into license (license_id, SKU,contract_id,asset_id) values (11,03,07,05);
insert into license (license_id, SKU,contract_id,asset_id) values (12,03,07,06);

Manager
create table manager (manager_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name
varchar(30));
insert into manager values (01,"Allan Amorim");
insert into manager values (02,"Will Camara");

Staff
CREATE TABLE staff ( staff_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, name
VARCHAR(30), role VARCHAR(15), manager_id VARCHAR(3) );
insert into staff values (01,"Allan Amorim",01);
insert into staff values (02,"Will Camara",02);
insert into staff values (03,"Lisa Malady",01);
insert into staff values (04,"Matt Sauerbrown",01);
insert into staff values (05,"Brian Adams",02);
insert into staff values (06,"Gabriel Kalliman",02);

Devices
CREATE TABLE device (asset_id INT NOT NULL, device_type VARCHAR(30) NOT NULL,
device_name VARCHAR(30) NOT NULL, staf_id VARCHAR(30), PRIMARY KEY (asset_id));
/* 2. INCLUDING INITAL DEVICE DATA */
insert into device values (asset_id, device_type, staf_id) values (01,"notebook",01);
insert into device values (02,"desktop",01);
insert into device values (03,"notebook",02);
insert into device values (04,"destktop",02);
insert into device values (05,"tablet",02);
insert into device values (06,"notebook",03);
/* a new column was created later for device name */
insert into device (asset_id, device_type, staf_id, device_name) values (07,"netbook",07,
"Apple netbook");
insert into device (asset_id, device_type, staf_id, device_name) values
(08,"desktop",07,"Lenovo All-in-One");

/* couting types of device */


select device_type, count(device_type) as quantity from device group by device_type;
SQL Query to Business Insights
SELECT Query with condition
Devices per employee view

CREATE VIEW Device_per_Employee AS


SELECT staff.name AS Name, device.device_name AS Device, software.Software_name AS
'Software installed'
FROM staff, license, device, software
WHERE staff.staff_id = device.staff_id
AND device.asset_id = license.asset_id
AND license.SKU = software.sku;

This query answers questions such as "How many devices does each employee have" and
"What devices does employee X have available". It can be used when you need to buy new
equipment and know if employees have devices available.
Group by query
Counting how employee have a specific software using group by

SELECT `Software installed`, count (`Software installed`) as Quantity from


Device_per_employee group by `Software installed`;

This query answers questions such as "How many employees have X software" and can be
used when we need to examine whether all employees have access to the software, they need
to do their jobs.
Join Query
View for software name - license

SELECT device.device_name, license.license_id, contract.`Expiry date`


FROM device 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;
Create view licenses_installed as
SELECT device.device_name, license.license_id, contract.`Expiry date`
FROM device
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;

This query answers questions such as "How much will be the expiration date of software
installed on machines" and "What software installed is closest to having its expiration date",
and can be used when we need to know which software to renew the subscription and using
this information, do the right decisions.

For a future update, this same query can be arranged in a variety of ways, like as device type, if
we wish to assume that notebooks will require Windows 8 and desktops will have Windows
10.
Nested Query
Find software that is about to expire

SELECT software_name, device_name, `Expiry date`


FROM installed
WHERE `Expiry date` IN (SELECT `Expiry date`
FROM installed
WHERE YEAR(`Expiry date`) < 2022)
ORDER BY `Expiry date` ASC;

This query complements the one developed earlier, giving a more accurate idea of exactly
what software is due for expiration.
Data Visualization

If there are duplicate licenses, the information about how much software per device may
reveal them.

It does not happen in our scenario because each device only has one type of software.
However, it can show which device has more software installed than the others, allowing for a
review of the requirement for too many apps in a single device.

Visualizations that show the requirement for renewal or the risk of receiving an unauthorised
item are essential. Contract number 5 is going to expire in this case, and it should be reviewed.
Some updates, on the other hand, may be postponed or delayed by reviewing log contracts.
For example, if the license for Windows 8 is active for nearly a year and is already paid for, a
Windows 8 replacement for Windows 10 may not be recommended.
The presentation of how many and what types of software are in use may lead to knowledge
about a company's bias and tendencies, as well as a plan for upgrading. Simultaneously, some
representations of how many netbooks, tablets, or notebooks each employee has are
beneficial. It is normal to have one notebook and one desktop, but why does Willian have two
gadgets of the same type? Why does one of the staff members have two notebooks? Is there a
cause for this, or is it just a case of bad asset allocation? The display of how many and what
sorts of software are in use can provide insight into a company's biases and trends, as well as a
strategy for upgrading. At the same time, certain visual depictions of how many netbooks,
tablets, or notebooks each employee owns are useful. It's common to have one notebook and
one desktop computer, but why does Willian have two identical devices? Why is it that one of
the members of the staff has two notebooks? Is there a reason for this, or is it simply a result
of poor asset allocation?

You might also like