alexrockelli.files.wordpress.com file · web viewteam northern ireland: monica naderi-colon, julian...

28
Team Northern Ireland: Monica Naderi-Colon, Julian Nelson, Alex Rockelli, Laura Streaman Database Deliverable 6/19/17

Upload: trinhkhanh

Post on 12-Apr-2019

214 views

Category:

Documents


0 download

TRANSCRIPT

Team Northern Ireland:Monica Naderi-Colon, Julian Nelson, Alex Rockelli, Laura Streaman

Database Deliverable

6/19/17

Table of Contents

Entity Relationship Diagram (ERD)…………………………………….. 1

Relational Schemata…………………………………………………………. 2

Domain Definitions and Valid Values………………………………… 3

Create Table Statements…………………………………………………… 4

Data Entry Statements……………………………………………………….6

Transactions……………………………………………………………………. 10

Queries and Results………………………………………………………… 12

Index Creation……………………………………………………………….. 17

Stored Procedure………………………………………………............... 17

SQL Server Gaelic Translation…………………………………………. 18

Multiple Currency Considerations…………………………………… 19

Entity Relationship Diagram (ERD)

1

Relational Schemata

CUSTOMER (CustomerID, FirstName, LastName, CreditCardNum, Email, Age, StreetAddress, City, State, Zip, Country)

COMPANY (CoName, Region, PhoneNum, Email, BillingAddress)

EMPLOYEE (EmpID, CoName, Name, PhoneNum, JobDescription, ManagerID, Salary, HireYear, YearsEmployed)

FK CoName COMPANYFK ManagerID EMPLOYEE

EMP_SKILL (EmpID, CoName, Skill)FK EmpID EMPLOYEEFK CoName COMPANY

DESTINATION (DestID, Region, StartingPoint)

ACCOMM (AccommID, Address, Region, Type, NumGuest)

SCHEDULE (SchedID, DestID, CoName, CustomerID, AccommID, Time, TransportationType, GroupSize)

FK DestID DESTINATIONFK CoName COMPANYFK CustomerID CUSTOMERFK AccommID ACCOMM

INVOICE (InvoiceID, Price, CustomerID, CoName, SchedID, PrePaid)FK CustomerID CUSTOMERFK CoName COMPANYFK SchedID SCHEDULE

POLICY (PolicyID, Description, Price, CustomerID)FK CustomerID CUSTOMER

EMERGE_CONTACT (ContactID, ContactName, PhoneNum, Email, CustomerID, Relationship)FK CustomerID CUSTOMER

2

Domain Definitions and Valid Values

The datatypes we used in our project are: VarChar, Numeric, Char, Int, Date, and Money. The field determined the datatype used. For example, we used VarChar if the field’s string length could vary by having a range of characters. This is the case for first and last names of customers. We then logically declared boundaries for VarChar fields. Other examples of fields with the VarChar datatype of varying lengths are: credit card number, city, and zip code. We used Numeric if the field would be subject to change and or used in a mathematical calculation. An example of Numeric is the year an employee was hired. This figure was used in a calculation to determine how many years each employee has been employed, which is why we used Numeric for the data. We used Char if the field had a fixed string length and wasn’t going to be changed for each record. An example of Char is state abbreviation which is always two letters in our database. We used Int when we wanted the data element to be a whole number. An example of this is employee ID. The Date datatype was used for formatting the schedule date field which required the data to be presented as “MM/DD/YY.” We also used the Money datatype in our invoice table for price because we need to accept multiple types of currency.

3

Create Table Statements

--Create Customer TableCreate Table Customer(CustomerID VarChar(25) Not Null, FirstName VarChar(25), LastName VarChar(50), CreditCardNum VarChar(25), Email VarChar(25), Age Numeric(11,0), StreetAddress VarChar(50), City VarChar(25), State Char(2), ZipCode VarChar(25), Country VarChar (50), Constraint Customer_PK Primary Key(CustomerID));

--Create Company TableCreate Table Company(CoName VarChar(50) Not Null, Region VarChar(50), PhoneNum VarChar(25), Email VarChar(25), BillingAddress VarChar(255), Constraint Company_PK Primary Key(CoName));

--Create Employee TableCreate Table Employee(EmpID int Not Null, CoName VarChar(50), Name VarChar(255), PhoneNum VarChar(25), JobDescription VarChar(255), ManagerID VarChar(25), Constraint Employee_PK Primary Key(EmpID, CoName), Constraint Employee_FK Foreign Key(CoName) REFERENCES Company(CoName));

--Create Table for Employees' SkillsCreate Table EmpSkill(EmpID int, CoName VarChar(50) Foreign Key References Company(CoName), Skill VarChar(255),Constraint EmpSkill_PK Primary Key(EmpID, CoName, Skill),Constraint EmpSkill_FK Foreign Key(EmpID, CoName) References Employee(EmpID, CoName));

--Create the Destination TableCreate Table Destination(DestID VarChar(255) Not Null Primary Key, Region VarChar(255), StartingPoint VarChar(255));

--Create the Accommodation TableCreate Table Accomm(AccommID VarChar(50) Not Null, Address VarChar(255) Not Null, Region VarChar(255), Type VarChar(50) Primary Key (AccommID));

4

--Create the Schedule TableCreate Table Schedule(SchedID VarChar(255) Not Null Primary Key, DestID VarChar(255) Foreign Key References Destination(DestID), CoName VarChar(50) Foreign Key References Company(CoName), CustomerID VarChar(25) Foreign Key References Customer(CustomerID), AccommID VarChar(50) Foreign Key References Accomm(AccommID),Time date DEFAULT GETDATE(), TransportType VarChar(255));

--Create the Invoice Table Create Table Invoice(InvoiceID int IDENTITY(1,1) Not Null Primary Key, Price Money Not Null, CustomerID VarChar(25) FOREIGN KEY REFERENCES Customer(CustomerID),CoName VarChar(50) FOREIGN KEY REFERENCES Company(CoName), SchedID VarChar(255) FOREIGN KEY REFERENCES Schedule(SchedID));

--Create the Policy TableCreate Table Policy(PolicyID VarChar(25) Not Null Primary Key, Description VarChar(255), Price Numeric(19,2),CustomerID VarChar(25) FOREIGN KEY REFERENCES Customer(CustomerID));

--Create the Emergency Contact TableCreate Table EmergeContact(ContactID VarChar(25) Not Null Primary Key, ContactName VarChar(100), PhoneNum VarChar(100), Email VarChar(100), CustomerID VarChar(25) FOREIGN KEY REFERENCES Customer(CustomerID));

5

Data Entry Statements

--Insert Data in Customer TableINSERT INTO Customer VALUES ('001', 'Alex', 'Rockelli', '123456789012', '[email protected]', 22, '137 S Main St', 'Harrisonburg', 'VA', '22801', 'USA')INSERT INTO Customer VALUES ('002', 'Julian', 'Nelson', '098765432109', '[email protected]', 21, '300 N Turn Ln', 'Harrisonburg', 'VA', '22807', 'USA')INSERT INTO Customer VALUES ('003', 'Laura', 'Streaman', '112233445566', '[email protected]', 22, '1738 Broad St', 'Harrisonburg', 'VA', '22801', 'USA')INSERT INTO Customer VALUES ('004', 'Monica', 'Naderi-Colon', '109283475643', '[email protected]', 21, '217 E Market St', 'Harrisonburg', 'VA', '22801', 'USA')INSERT INTO Customer VALUES ('005', 'Carey', 'Cole', '012348864212', '[email protected]', 58, '1600 Pennsylvania Ave NW', 'Washington, D.C.', Null, '20500', 'USA')INSERT INTO Customer VALUES ('006', 'oIP', 'JMU Abroad', '555731429098', '[email protected]', Null, '800 S Main St', 'Harrisonburg', 'VA', '22801', 'USA')INSERT INTO Customer VALUES ('007', 'James', 'Madison', Null, '[email protected]', 100, '800 S Main St', 'Harrisonburg', 'VA', '22801', 'USA')INSERT INTO Customer VALUES ('008', 'Lebron', 'James', '121234343232', '[email protected]', 31, '12 Castle Dr', 'Cleveland', 'OH', '54432', 'USA')INSERT INTO Customer VALUES ('009', 'Bryce', 'Harper', '098890769043', '[email protected]', 24, '3247 S Liberty St', 'Arlington', 'VA', '22205', 'USA')INSERT INTO Customer VALUES ('010', 'Peyton', 'Manning', '333555678921', '[email protected]', 41, '212 N Touchdown Dr', 'Denver', 'CO', '31117', 'USA')INSERT INTO Customer VALUES ('011', 'Johnny', 'Cash', '555732212311', Null, 30, '1 Classic Rock Pl', 'Jonesboro', 'AR', '89090', 'USA')Select * from Customer;

--Insert Data for Company TableINSERT INTO Company VALUES ('Paddy Wagon', 'Whole country', '(+353) 1 823 0822', '[email protected]', '5 Beresford Place Lower Gardiner Street, Dublin 1')INSERT INTO Company VALUES ('DayTours', 'Whole country', '(+353) 1 410 0700', '[email protected]', '37 College Green, Dublin 2') INSERT INTO Company VALUES ('RailTours Ireland', 'Whole country', '(+353) 1 856 0045', '[email protected]', '16 Amiens Street, Dublin 1')Select * from Company;

6

--Insert Data into Employee tableINSERT INTO Employee VALUES ('004', 'Paddy Wagon', 'Tom Wilbert', '(+353) 1 342 5367', 'Walking Tour Guide', Null)INSERT INTO Employee VALUES ('035', 'Paddy Wagon', 'Karen Johnson', '(+353) 1 680 2116', 'Tour Office Manager', 13)INSERT INTO Employee VALUES ('117', 'Paddy Wagon', 'Matt Streck', '(+353) 1 912 2781', 'Bus Driver', 22)INSERT INTO Employee VALUES ('001', 'DayTours', 'Daniel Sugrue', '(+353) 1 333 5556', 'Tech Analyst', 4)INSERT INTO Employee VALUES ('201', 'DayTours', 'John Elway', '(+353) 1 334 5256', 'General Manager', 1)INSERT INTO Employee VALUES ('016', 'RailTours Ireland', 'Claire Patrick', '(+353) 1 126 5291', 'Private Tour Specialist', 10)INSERT INTO Employee VALUES ('004', 'RailTours Ireland', 'Jack Jamison', '(+353) 1 754 2146', 'Accountant', 2)Select * From Employee;

--Insert Data into the Employee Skill TableINSERT INTO EmpSkill VALUES ('004', 'RailTours Ireland', 'Microsoft Excel')INSERT INTO EmpSkill VALUES ('016', 'RailTours Ireland', 'Interpersonal Skills') INSERT INTO EmpSkill VALUES ('004', 'Paddy Wagon', 'Walking, Talking')Select * from EmpSkill;

--Insert Data into the Destination TableINSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Cliffs of Moher', 'West', 'Dublin')INSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Giants Causeway', 'Northeast', 'Dublin')INSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Wicklow', 'Southeast', 'Dublin')INSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Ring of Kerry', 'Southwest', 'Galway')INSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Blarney Castle', 'South', 'Dublin')INSERT INTO Destination (DestID, Region, StartingPoint) VALUES ('Aviva Stadium', 'East', 'Dublin')Select * from Destination;

7

--Insert Data into the Accommodation Table INSERT INTO Accomm (AccommID, Address, Region, Type) VALUES ('Cliffs of Moher Hotel', 'Main St, Liscannor', 'West', 'Hotel')INSERT INTO Accomm (AccommID, Address, Region, Type) VALUES ('Causeway Hotel', '40 Causeway Road, Bushmills', 'Northeast', 'Hotel')INSERT INTO Accomm (AccommID, Address, Region, Type) VALUES ('Wicklow Way Lodge Bed & Breakfast', 'Roundwood', 'Southeast', 'Bed&Breakfast')INSERT INTO Accomm (AccommID, Address, Region, Type) VALUES ('Ring of Kerry Hostel', 'Killarney', 'Southwest', 'Hostel')INSERT INTO Accomm (AccommID, Address, Region, Type) VALUES ('Blarney Castle Hotel', 'Cork', 'Southeast', 'Hotel')Select * from Accomm;

--Insert Data into the Schedule Table INSERT INTO Schedule VALUES ('A1001', 'Blarney Castle', 'Paddy Wagon', '001', Null, '06/15/17', 'Bus')INSERT INTO Schedule VALUES ('A1005', 'Wicklow', 'Paddy Wagon', '002', 'Wicklow Way Lodge Bed & Breakfast', '06/9/17', 'Bus')INSERT INTO Schedule VALUES ('B1701', 'Wicklow', 'Paddy Wagon', '003', 'Wicklow Way Lodge Bed & Breakfast', '06/9/17', 'Bus')INSERT INTO Schedule VALUES ('M0021', 'Aviva Stadium', 'DayTours', '001', Null, '06/04/17', 'Walking')INSERT INTO Schedule VALUES ('T3305', 'Ring of Kerry', 'DayTours', '009', 'Ring of Kerry Hostel', '11/23/17', 'Private Tour')INSERT INTO Schedule VALUES ('T3425', 'Blarney Castle', 'DayTours', '009', 'Blarney Castle Hotel', '11/25/17', 'Private Tour')INSERT INTO Schedule VALUES ('T3560', 'Ring of Kerry', 'DayTours', '008', 'Ring of Kerry Hostel', '11/23/17', 'Private Tour')INSERT INTO Schedule VALUES ('T2201', 'Ring of Kerry', 'DayTours', '010', 'Ring of Kerry Hostel', '10/23/17', 'Private Tour')Select * from Schedule;

--Insert Data into the Invoice Table INSERT INTO Invoice VALUES ($50.00, '001', 'Paddy Wagon', 'A1001')INSERT INTO Invoice VALUES ($135.00, '002', 'Paddy Wagon', 'A1005')INSERT INTO Invoice VALUES ($135.00, '003', 'Paddy Wagon', 'B1701')INSERT INTO Invoice VALUES ($120.00, '001', 'DayTours', 'M0021')INSERT INTO Invoice VALUES ($83.00, '009', 'DayTours', 'T3305')INSERT INTO Invoice VALUES ($240.00, '009', 'DayTours', 'T3425')INSERT INTO Invoice VALUES ($90.00, '008', 'DayTours', 'T3560')INSERT INTO Invoice VALUES ($83.00, '010', 'DayTours', 'T2201')select * from Invoice;

8

--Insert Data into the Policy TableINSERT INTO Policy VALUES ('001', 'General Travel Insurance: reimbursement for transportation', 30.00, '003')INSERT INTO Policy VALUES ('002', 'Upgraded Travel Insurance: reimbursement for transportation and food', 50.00, Null)INSERT INTO Policy VALUES ('003', 'Full Travel Insurance: total reimbursement', 100.00, '002')select * from Policy;

--Insert Data into the Emergency Contact Table INSERT INTO EmergeContact VALUES ('AA100', 'Andy Rockelli', '7039691640', '[email protected]', '001')INSERT INTO EmergeContact VALUES ('BB100', 'Connor Streaman', '5816561165', '[email protected]', '003')INSERT INTO EmergeContact VALUES ('CC100', 'DonnaSheryl Nelson', '5759789854', '[email protected]', '002')INSERT INTO EmergeContact VALUES ('DC100', 'Papi Naderi', '9854345678', '[email protected]', '004')INSERT INTO EmergeContact VALUES ('EE100', 'Becky Cole', Null, 'DogLover123gmail.com', '005')INSERT INTO EmergeContact VALUES ('GG100', 'Dolly Madison', '1239789854', '[email protected]', '007')INSERT INTO EmergeContact VALUES ('RR100', 'Mrs. James', '4042786674', '[email protected]', '008')INSERT INTO EmergeContact VALUES ('ZZ100', 'Eli Manning', Null, '[email protected]', '010')INSERT INTO EmergeContact VALUES ('CM100', 'Cold Hard Cash', '1800555223', Null, '011')INSERT INTO EmergeContact VALUES ('BK100', 'Krista Harper', '5559785554', '[email protected]', '009')INSERT INTO EmergeContact VALUES ('XX100', 'JMU Judicial', '5402260000', '[email protected]', '006')Select * from EmergeContact;

9

Transactions

--1 Add Salary Column to Employee TableALTER TABLE Employee ADD Salary Money;UPDATE Employee SET Salary = 30000 Where CoName = 'Paddy Wagon' AND NOT JobDescription = 'Tour Office Manager'UPDATE Employee SET Salary = 55000 Where EmpID = '035'UPDATE Employee SET Salary = 42000 Where CoName LIKE '%Ireland'UPDATE Employee SET Salary = 150000 Where Name = 'John Elway'UPDATE Employee SET Salary = 65000 Where CoName = 'DayTours' AND EmpID = '001'Select * From Employee;

--2 Add the Year Employees were Hired to the Employee TableALTER Table Employee ADD HireYear Numeric(6,0);UPDATE Employee SET HireYear = 2016 Where Name LIKE 'Daniel%';UPDATE Employee SET HireYear = 2009 Where Name LIKE 'Karen%';UPDATE Employee SET HireYear = 2014 Where Name LIKE 'Tom%';UPDATE Employee SET HireYear = 2015 Where Name LIKE '%Streck';UPDATE Employee SET HireYear = 2002 Where Name LIKE '%Elway';UPDATE Employee SET HireYear = 2011 Where CoName = 'RailTours Ireland';Select * From Employee;

--3 Add Derived Attribute YearsEmployed to Employee Table ALTER Table Employee ADD YearsEmployed as 2017 - HireYear;Select * from Employee;

--4 Fire Daniel from DayTours, if you want toDELETE FROM Employee WHERE EmpID = '001';

--5 Change the Name of a Destination already in the Destination Table UPDATE Destination SET DestID = 'Super Scary Cliffs of Moher' Where Region = 'West';Select * From Destination;

--6 Show the Maximum Number of Guests each Accommodation can supportALTER TABLE Accomm ADD NumGuest Numeric(11,0);UPDATE Accomm SET NumGuest = 50 Where AccommID = 'Cliffs of Moher Hotel'UPDATE Accomm SET NumGuest = 25 Where AccommID LIKE '%Bed%'UPDATE Accomm SET NumGuest = 100 Where Region = 'Northeast'UPDATE Accomm SET NumGuest = 200 Where AccommID = 'Blarney Castle Hotel'UPDATE Accomm SET NumGuest = 75 Where Address = 'Killarney'Select * From Accomm;

10

--7 Add the size of the group to each scheduleALTER TABLE Schedule ADD GroupSize int;UPDATE Schedule SET GroupSize = 8 WHERE SchedID = 'A1001'UPDATE Schedule SET GroupSize = 5 WHERE SchedID = 'A1005'UPDATE Schedule SET GroupSize = 4 WHERE SchedID = 'B1701'UPDATE Schedule SET GroupSize = 2 WHERE SchedID = 'M0021'UPDATE Schedule SET GroupSize = 1 WHERE SchedID = 'T3305'UPDATE Schedule SET GroupSize = 1 WHERE SchedID = 'T3425'UPDATE Schedule SET GroupSize = 20 WHERE SchedID = 'T3560'UPDATE Schedule SET GroupSize = 12 WHERE SchedID = 'T2201'Select * From Schedule;

--8 Display whether or not customers have prepaid their invoices before the trip Alter Table Invoice ADD PrePaid VarChar(25)UPDATE Invoice SET PrePaid = 'Yes' Where CustomerID = '001'UPDATE Invoice SET PrePaid = 'No' Where CustomerID = '002'UPDATE Invoice SET PrePaid = 'Yes' Where SchedID = 'B1701'UPDATE Invoice SET PrePaid = 'Yes' Where InvoiceID > 3Select * From Invoice;

--9 Add to the Emergency Contact Table the relationship between Customer and their ContactAlter Table EmergeContact ADD Relationship VarChar(25)UPDATE EmergeContact SET Relationship = 'Brother' Where ContactID = 'AA100'UPDATE EmergeContact SET Relationship = 'Brother' Where ContactID = 'BB100'UPDATE EmergeContact SET Relationship = 'Mother' Where ContactID = 'CC100'UPDATE EmergeContact SET Relationship = 'Immediate Family' Where CustomerID > 3Select * From EmergeContact;

--10 Drop a Column from a Table Alter Table Employee DROP COLUMN Salary;Select * From Employee;

11

Queries and Results

--1 Show Customer ID#s and First & Last NamesSelect Distinct Customer.CustomerID, FirstName, LastName From CustomerCustomerID FirstName LastName001 Alex Rockelli002 Julian Nelson003 Laura Streaman004 Monica Naderi-Colon005 Carey Cole006 oIP JMU Abroad007 James Madison008 Lebron James009 Bryce Harper010 Peyton Manning011 Johnny Cash

--2 Show Insurance Policies under $50.00Select PolicyID, Description, Price From Policy Where Price <= 50;PolicyID Description Price001 General Travel Insurance: reimbursement for transportation 30.00002 Upgraded Travel Insurance: reimbursement for transportation and food 50.00

--3 Show all customer info for Carey ColeSelect * From Customer Where FirstName = 'Carey';CustomerID FirstName LastName CreditCardNum Email Age005 Carey Cole 012348864212 [email protected] 58StreetAddress City State ZipCode Country1600 Pennsylvania Ave NW Washington, D.C. NULL 20500 USA

--4 Show all Customers including those who have and haven't booked a trip scheduleSelect Customer.CustomerID, FirstName, LastName, SchedID From Customer LEFT JOIN Schedule ON Customer.CustomerID = Schedule.CustomerID;CustomerID FirstName LastName SchedID001 Alex Rockelli A1001001 Alex Rockelli M0021002 Julian Nelson A1005003 Laura Streaman B1701004 Monica Naderi-Colon NULL005 Carey Cole NULL006 oIP JMU Abroad NULL007 James Madison NULL

12

008 Lebron James T3560009 Bryce Harper T3305009 Bryce Harper T3425010 Peyton Manning T2201011 Johnny Cash NULL

--5 Only show customers who have booked at least one trip scheduleSelect Customer.CustomerID, FirstName, LastName, SchedID From Customer RIGHT JOIN Schedule ON Customer.CustomerID = Schedule.CustomerID;CustomerID FirstName LastName SchedID001 Alex Rockelli A1001002 Julian Nelson A1005003 Laura Streaman B1701001 Alex Rockelli M0021010 Peyton Manning T2201009 Bryce Harper T3305009 Bryce Harper T3425008 Lebron James T3560

--6 Show Emergency Contacts for each CustomerSelect Customer.CustomerID, LastName, ContactID, ContactName, EmergeContact.PhoneNum, Relationship From EmergeContact INNER JOIN Customer ON EmergeContact.CustomerID = Customer.CustomerID Order By Customer.CustomerID;CustomerID LastName ContactID ContactName PhoneNum Relationship001 Rockelli AA100 Andy Rockelli 7039691640 Brother002 Nelson CC100 DonnaSheryl Nelson 5759789854 Mother003 Streaman BB100 Connor Streaman 5816561165 Brother004 Naderi-Colon DC100 Papi Naderi 9854345678 Immediate Family005 Cole EE100 Becky Cole NULL Immediate Family006 JMU Abroad XX100 JMU Judicial 5402260000 Immediate Family007 Madison GG100 Dolly Madison 1239789854 Immediate Family008 James RR100 Mrs. James 4042786674 Immediate Family009 Harper BK100 Krista Harper 5559785554 Immediate Family010 Manning ZZ100 Eli Manning NULL Immediate Family011 Cash CM100 Cold Hard Cash 1800555223 Immediate Family

--7 Show Customers' Schedules, Destination, and Prices for their bookingsSelect Customer.CustomerID, FirstName, LastName, Schedule.SchedID, DestID, Invoice.Price From Customer, Schedule, Invoice Where Customer.CustomerID = Invoice.CustomerID AND Schedule.SchedID = Invoice.SchedID Order By Customer.CustomerID;CustomerID FirstName LastName SchedID DestID Price001 Alex Rockelli A1001 Blarney Castle 50.00001 Alex Rockelli M0021 Aviva Stadium 120.00002 Julian Nelson A1005 Wicklow 135.00

13

003 Laura Streaman B1701 Wicklow 135.00008 Lebron James T3560 Ring of Kerry 90.00009 Bryce Harper T3305 Ring of Kerry 83.00009 Bryce Harper T3425 Blarney Castle 240.00010 Peyton Manning T2201 Ring of Kerry 83.00

--8 Show available Accommodations for destinations in the Northeast Region of IrelandSelect AccommID as Place, Region, NumGuest From Accomm Where Region = 'Northeast';Place Region NumGuestCauseway Hotel Northeast 100

--9 Show Employees ordered by highest salarySelect EmpID, CoName, Name, JobDescription as Position, Salary From Employee Order By Salary DESC;EmpID CoName Name Position Salary201 DayTours John Elway General Manager 150000.001 DayTours Daniel Sugrue Tech Analyst 65000.0035 Paddy Wagon Karen Johnson Tour Office Manager 55000.004 RailTours Ireland Jack Jamison Accountant 42000.0016 RailTours Ireland Claire Patrick Private Tour Specialist 42000.004 Paddy Wagon Tom Wilbert Walking Tour Guide 30000.00117 Paddy Wagon Matt Streck Bus Driver 30000.00

--10 Show all Employees including those without listed skillsSelect Employee.EmpID, Employee.CoName as Company, Name, JobDescription, Skill From EmpSkill RIGHT JOIN Employee ON EmpSkill.EmpID = Employee.EmpID AND EmpSkill.CoName = Employee.CoName;EmpID Company Name JobDescription Skill1 DayTours Daniel Sugrue Tech Analyst NULL4 Paddy Wagon Tom Wilbert Walking Tour Guide Walking, Talking4 RailTours Ireland Jack Jamison Accountant Microsoft Excel16 RailTours Ireland Claire Patrick Private Tour Specialist Interpersonal Skills35 Paddy Wagon Karen Johnson Tour Office Manager NULL117 Paddy Wagon Matt Streck Bus Driver NULL201 DayTours John Elway General Manager NULL

--11 Only show Employees with listed skillsSelect Distinct Employee.EmpID, Employee.CoName, Name, JobDescription, Skill From EmpSkill LEFT JOIN Employee ON EmpSkill.EmpID = Employee.EmpID AND EmpSkill.CoName = Employee.CoName;EmpID CoName Name JobDescription Skill4 Paddy Wagon Tom Wilbert Walking Tour Guide Walking, Talking4 RailTours Ireland Jack Jamison Accountant Microsoft Excel16 RailTours Ireland Claire Patrick Private Tour Specialist Interpersonal Skills

14

--12 Show Employees by who has worked the fewest years for each companySelect CoName, Name, YearsEmployed From Employee Order By YearsEmployed ASC;CoName Name YearsEmployedDayTours Daniel Sugrue 1Paddy Wagon Matt Streck 2Paddy Wagon Tom Wilbert 3RailTours Ireland Jack Jamison 6RailTours Ireland Claire Patrick 6Paddy Wagon Karen Johnson 8DayTours John Elway 15

--Unions--1 Show Schedule Accommodations even if not every schedule has an accommodationSelect Distinct Accomm.AccommID as Place From Accomm Union ALL Select Schedule.AccommID From Schedule;PlaceBlarney Castle HotelCauseway HotelCliffs of Moher HotelRing of Kerry HostelWicklow Way Lodge Bed & BreakfastNULLWicklow Way Lodge Bed & BreakfastWicklow Way Lodge Bed & BreakfastNULLRing of Kerry HostelRing of Kerry HostelBlarney Castle HotelRing of Kerry Hostel

--2 Show Company Billing Addresses and Prepay OptionsSelect BillingAddress as 'Billing Addresses and Prepay Options' From Company Union Select PrePaid From Invoice;Billing Addresses and Prepay Options16 Amiens Street, Dublin 137 College Green, Dublin 25 Beresford Place Lower Gardiner Street, Dublin 1NoYes

15

--3 Show all non-Employee names in systemSelect Customer.CustomerID as SystemID, FirstName, LastName as 'LastName or Relationship' From Customer Union Select ContactID, COntactName, Relationship From EmergeContact Order by Customer.CustomerID;SystemID FirstName LastName or Relationship001 Alex Rockelli002 Julian Nelson003 Laura Streaman004 Monica Naderi-Colon005 Carey Cole006 oIP JMU Abroad007 James Madison008 Lebron James009 Bryce Harper010 Peyton Manning011 Johnny CashAA100 Andy Rockelli BrotherBB100 Connor Streaman BrotherBK100 Krista Harper Immediate FamilyCC100 DonnaSheryl Nelson MotherCM100 Cold Hard Cash Immediate FamilyDC100 Papi Naderi Immediate FamilyEE100 Becky Cole Immediate FamilyGG100 Dolly Madison Immediate FamilyRR100 Mrs. James Immediate FamilyXX100 JMU Judicial Immediate FamilyZZ100 Eli Manning Immediate Family

--Team Northern Ireland NicknamesSelect UPPER(SUBSTRING(FirstName, 1,1) + ' ' + SUBSTRING(LastName, 1,4)) as 'Northern Ireland Team Nicknames' From Customer Where CustomerID Between '001' and '004';Northern Ireland Team NicknamesA ROCKJ NELSL STREM NADE

16

Index Creation

--Create Index for Customer Table on Customers' LastName Create Index idx_LastName on Customer(LastName);

Stored Procedure

--STORED PROCEDURE for displaying Emergency Contact informationCreate Procedure ShowContact @ContactID VarChar(25) as

Select ContactName, '(' + Substring(EmergeContact.PhoneNum, 1, 3) + ')' + ' ' + SUBSTRING(EmergeContact.PhoneNum,4,3) + '-' + Substring(EmergeContact.PhoneNum, 7, 10) as 'Phone Number',

EmergeContact.Email, EmergeContact.CustomerID, SUBSTRING(Customer.FirstName, 1, 10) + ' ' + SUBSTRING(LastName, 1, 15) as CustomerFrom EmergeContact, CustomerWhere ContactID = @ContactID AND EmergeContact.CustomerID =

Customer.CustomerID;

--Run Stored Procedure for Emergency ContactsExec ShowContact @ContactID = 'BB100';Exec ShowContact @ContactID = 'ZZ100';Exec ShowContact @ContactID = 'GG100';

17

SQL Server Gaelic Translation

To translate our SQL Server in English to Gaelic, our team would hire two independent professional translators. The first would translate the statements into Gaelic, and the second would translate the statements from Gaelic back to English to ensure they match the original English statements. The purpose of hiring two independent professional translators is to verify the statements are accurately translated to Gaelic and back to English without losing any intended nor functional meaning. Also, we will personally cross-reference the translators’ work with our own third method of translation using Google Translate. Here is an example using Google Translate of Create and Insert statements for our Policy table. The English SQL Server is shown first, then its corresponding Gaelic translation: Create Table Policy(PolicyID VarChar(25) Not Null Primary Key, Description VarChar(255), Price Numeric(19,2),CustomerID VarChar(25) FOREIGN KEY REFERENCES Customer(CustomerID));INSERT INTO Policy VALUES ('001', 'General Travel Insurance: reimbursement for transportation', 30.00, '003')INSERT INTO Policy VALUES ('002', 'Upgraded Travel Insurance: reimbursement for transportation and food', 50.00, Null)INSERT INTO Policy VALUES ('003', 'Full Travel Insurance: total reimbursement', 100.00, '002')select * from Policy; Cruthaigh Polasaí Tábla(PolicyID varchar (25) Tráth nach nialasacha Bunscoileanna Key,Tuairisc varchar (255),Praghas Uimhriúil (19,2),CustomerID varchar (25) EOCHAIR EACHTRACH TAGAIRTÍ Chustaiméirí (CustomerID));CUIR ISTEACH LUACHANNA Polasaí ('001', 'Ginearálta Árachas Taistil: aisíocaíocht as iompar', 30.00, '003')CUIR ISTEACH LUACHANNA Polasaí ('002', 'Uasghrádaithe Árachas Taistil: aisíocaíocht as iompar agus bia', 50.00, Null)CUIR ISTEACH LUACHANNA Polasaí ('003', 'Iomlán Árachas Taistil: aisíoc iomlán', 100.00, '002')roghnaigh * ó Polasaí;

18

Multiple Currency Considerations

Our system offers customers the option to select their currency of choice when initially registering for an account. This is done for the customers’ convenience because after they choose a currency, all prices are displayed to them in the currency of their selection. For example, since all of our customers currently in the system are from the United States, they chose American dollars as their currencies. For this reason, the prices of the invoices in the system are shown in U.S. Dollars. This is our way of asking what currency customers want to be billed in. They make a selection, then we show them prices based on their selection.

19