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

GFC Query Script

The document creates a database called GrandfieldCollege and then defines several tables within that database to track software licenses, installations, machine locations, user machines, software requests, and the relationship between users and their requests. Tables are created for License, Software, Install, Location, Machine, User, UserMachine, Request, and RequestSoftwareUser with primary keys and foreign key relationships defined between the tables.

Uploaded by

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

GFC Query Script

The document creates a database called GrandfieldCollege and then defines several tables within that database to track software licenses, installations, machine locations, user machines, software requests, and the relationship between users and their requests. Tables are created for License, Software, Install, Location, Machine, User, UserMachine, Request, and RequestSoftwareUser with primary keys and foreign key relationships defined between the tables.

Uploaded by

Andrew Robinson
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

USE master

GO
IF EXISTS (SELECT name FROM sys.sysdatabases
WHERE name = 'GrandfieldCollege')
DROP DATABASE GranfieldCollege
GO
CREATE DATABASE GrandfieldCollege
GO
USE GrandfieldCollege
GO
Use GrandfieldCollege
GO
CREATE TABLE License
(
LicenseKey int Primary Key Not Null,
LicenseType NVarChar Not Null,
LicenseStart Date Not Null,
LicenseTerm NVarChar Not Null,
LicenseEnd Date Not Null,
LicenseRegistrationKey nvarchar(50) Not Null,
)
GO
CREATE TABLE Software
(
SoftwareKey int Primary Key Not Null,
SoftwareName NVarChar Not Null,
SoftwareVersion NVarChar Not Null,
SoftwareManufacturer NVarChar Not Null,
SoftwareInstallType NVarChar Not Null,
SoftwareLicence NVarChar Not Null,
LicenseKey int Not Null,
CONSTRAINT fk_License FOREIGN KEY(LicenseKey)
REFERENCES License(LicenseKey),
)
GO
CREATE TABLE Install
(
InstallKey int Primary Key Not Null,
InstallDate datetime Not Null,
InstallMachine NVarChar Not Null,
InstallSoftware NVarChar Not Null,
InstallSuccesful NVarChar Not Null,
SoftwareKey int Not Null,
CONSTRAINT fk_Software FOREIGN KEY(SoftwareKey)
REFERENCES Software (SoftwareKey),
)
GO
CREATE TABLE Location
(
LocationKey Nvarchar Not Null Primary Key,
BuildingName nvarchar(50) Not Null,
BuildingRoom Nvarchar (50) Not Null,
)
GO
CREATE TABLE Machine
(
MachineCSS int Primary Key Not Null,
MachineInstalledPrograms NvarChar Not Null,

MachineInstallDate NvarChar Not Null,


MachineConfiguration NvarChar Not Null,
LocationKey NvarChar Not Null,
InstallKey NvarChar Not Null,
CONSTRAINT fk_Location FOREIGN KEY(LocationKey)
REFERENCES Location(LocationKey),
CONSTRAINT fk_Install FOREIGN KEY(InstallKey)
REFERENCES Install(InstallKey)
)
GO
CREATE TABLE [User]
(
UserID NVarChar(64) Primary Key Not Null,
UserFirstName NVarChar Not Null,
UserLastName NVarChar Not Null,
)
GO
CREATE TABLE UserMachine
(
UserMachineID int Primary Key Not Null,
MachineCSS int Not Null,
UserID NVarChar(64) Not Null,
CONSTRAINT fk_Machine FOREIGN KEY(MachineCSS)
REFERENCES Machine(MachineCSS),
CONSTRAINT fk_User FOREIGN KEY(UserID)
REFERENCES [User](UserID)
)
GO
CREATE TABLE [Request]
(
RequestID int Primary Key Not Null,
RequesterFirst NVarChar Not Null,
RequesterLast NVarChar Not Null,
RequestDate Date Not Null,
RequestSoftware NVarChar Not Null,
RequestReason NVarChar Not Null,
RequestStatus NVarChar Not Null,
)
GO
CREATE TABLE RequestSoftwareUser
(
UserRequestID NVarChar Not Null Primary Key,
UserID NVarChar(64) Not Null,
RequestID int Not Null,
CONSTRAINT fk_UserID FOREIGN KEY (UserID)
REFERENCES [User](UserID),
CONSTRAINT fk_RequestID FOREIGN KEY (RequestID)
REFERENCES Request(RequestID),
)

You might also like