BMIS 325 CMS Project: Phase II Instructions

BMIS 325 CMS Project: Phase II Instructions In this phase, you will create tables based upon the ERD and SQL code below. You will then populate each table with the data presented below. Finally, you will create queries that will be used to support reports for Accounting and Management. You will not actually create the reports in a GUI environment– only the queries that will serve as the basis for the reports. Screenshots are required for a grade to be given.

Background : The following ERD will be used as the basis for this Phase. Part A: Table Creation and Data Loading Instructions : Create a new database in SQL Server and run the following CREATE TABLE commands. Note that you must run the CREATE TABLE statements in the order presented (and load the data in the order presented) to avoid conflicts resulting from foreign key constraints. Additional instructions for materials to turn in for this phase of your project are included at the end of this specification document.

CREATE TABLE Regions (RegionID int not null, RegionAbbreviation varchar(4), RegionName varchar(100), CONSTRAINT PK_Regions PRIMARY KEY (RegionID))

CREATE TABLE Countries (CountryID int not null, CountryName varchar(50), WeeklyHours int, Holidays int, VacationDays int, RegionID int, CONSTRAINT PK_Countries PRIMARY KEY (CountryID), CONSTRAINT FK_CountriesRegions FOREIGN KEY (RegionID) References Regions)

CREATE TABLE EmployeeTitles (TitleID int not null, Title varchar(15), CONSTRAINT PK_EmpTitles PRIMARY KEY (TitleID))

CREATE TABLE BillingRates (TitleID int not null, Level int not null, Rate float, CurrencyName varchar(5), CONSTRAINT PK_BillingRates PRIMARY KEY (TitleID, Level), CONSTRAINT FK_BillingRatesTitles FOREIGN KEY (TitleID) References EmployeeTitles)

CREATE TABLE Employees (EmpID int not null, FirstName varchar(30), LastName varchar(30), Email varchar(50), Salary decimal(10,2), TitleID int, Level int, SupervisorID int, CountryID int, CONSTRAINT PK_Employees PRIMARY KEY (EmpID), CONSTRAINT FK_EmployeesCountries FOREIGN KEY (CountryID) References Countries, CONSTRAINT FK_EmployeesEmpTitles FOREIGN KEY (TitleID) References EmployeeTitles, CONSTRAINT FK_EmployeeSupervisors FOREIGN KEY (SupervisorID) References Employees)

CREATE TABLE ContactTypes (ContactTypeID int not null, ContactType varchar(30) CONSTRAINT PK_ContactTypes PRIMARY KEY (ContactTypeID))

CREATE TABLE ContractTypes (ContractTypeID int not null, ContractType varchar(30) CONSTRAINT PK_ContractTypes PRIMARY KEY (ContractTypeID))

CREATE TABLE BenefitTypes (BenefitTypeID int not null, BenefitType varchar(30) CONSTRAINT PK_BenefitTypes PRIMARY KEY (BenefitTypeID))

CREATE TABLE Clients (ClientID int not null, LegalName varchar(50), CommonName varchar(50), AddrLine1 varchar(50), AddrLine2 varchar(50), City varchar(25), State_Province varchar(25), Zip varchar(9), CountryID int, CONSTRAINT PK_Clients PRIMARY KEY (ClientID), CONSTRAINT FK_ClientsCountries FOREIGN KEY (CountryID) REFERENCES Countries)

CREATE TABLE Contacts (ContactID int not null, FirstName varchar(50), LastName varchar(50), AddrLine1 varchar(50), AddrLine2 varchar(50), City varchar(25), State_Province varchar(25), Zip varchar(9), CountryID int, ContactTypeID int, CONSTRAINT PK_Contacts PRIMARY KEY (ContactID), CONSTRAINT FK_ContactsCountries FOREIGN KEY (CountryID) REFERENCES Countries)

CREATE TABLE ContractTypes (ContractTypeID int not null, ContractTypeDesc varchar(50), CONSTRAINT PK_ContractTypes PRIMARY KEY (ContractTypeID))

CREATE TABLE Contracts (ContractID int not null, ContractDesc varchar(100), ClientID int, ContractTypeID int, CONSTRAINT PK_Contracts PRIMARY KEY (ContractID), CONSTRAINT FK_ContractsClients FOREIGN KEY (ClientID) REFERENCES Clients, CONSTRAINT FK_ContractsContractTypes FOREIGN KEY (ContractTypeID) REFERENCES ContractTypes)

CREATE TABLE ContractsContacts (ContractID int not null, ContactID int not null, CONSTRAINT PK_ContractsContacts PRIMARY KEY (ContractID, ContactID), CONSTRAINT FK_CC_Contracts FOREIGN KEY (ContractID) REFERENCES Contracts, CONSTRAINT FK_CC_Contacts FOREIGN KEY (ContactID) REFERENCES Contacts)

CREATE TABLE Projects (ProjectID int not null, ProjectName varchar(50), HourCapAmount decimal(10,2), ProjectManagerID int, ContractID int, CONSTRAINT PK_Projects PRIMARY KEY (ProjectID), CONSTRAINT FK_ProjectsEmployees FOREIGN KEY (ProjectManagerID) REFERENCES Employees, CONSTRAINT FK_ProjectsContracts FOREIGN KEY (ContractID) REFERENCES Contracts)

CREATE TABLE EmployeesProjects (EmpID int not null, ProjectID int not null, StartDate smalldatetime, EndDate smalldatetime, CONSTRAINT PK_EmployeesProjects PRIMARY KEY (EmpID, ProjectID), CONSTRAINT FK_EP_Employees FOREIGN KEY (EmpID) REFERENCES Employees, CONSTRAINT FK_EP_Projects FOREIGN KEY (ProjectID) REFERENCES Projects)

CREATE TABLE Timesheets (TimesheetID int not null, SupervisorApproveDate smalldatetime, CONSTRAINT PK_Timesheets PRIMARY KEY (TimesheetID))

CREATE TABLE WorkHours (EmpID int not null, ProjectID int not null, WH_Day int not null, WH_Month int not null, WH_Year int not null, HoursWorked float, TimesheetID int, CONSTRAINT PK_WorkHours PRIMARY KEY (EmpID, ProjectID, WH_Day, WH_Month, WH_Year), CONSTRAINT FK_WorkHoursEmployees FOREIGN KEY (EmpID) REFERENCES Employees, CONSTRAINT FK_WorkHoursProjects FOREIGN KEY (ProjectID) REFERENCES Projects, CONSTRAINT FK_WorkHoursTimesheets FOREIGN KEY (TimesheetID) REFERENCES Timesheets)

CREATE TABLE BenefitsTaken (EmpID int not null, BenefitTypeID int not null, BT_Day int not null, BT_Month int not null, BT_Year int not null, HoursTaken float, TimesheetID int, CONSTRAINT PK_BenefitsTaken PRIMARY KEY (EmpID, BenefitTypeID, BT_Day, BT_Month, BT_Year), CONSTRAINT FK_BenefitsTakenEmployees FOREIGN KEY (EmpID) REFERENCES Employees, CONSTRAINT FK_BenefitsTakenBenefitTypes FOREIGN KEY (BenefitTypeID) REFERENCES BenefitTypes, CONSTRAINT FK_BenefitsTakenTimesheets FOREIGN KEY (TimesheetID) REFERENCES Timesheets)

Data Section

The following information is currently maintained in various spreadsheets throughout CMS. Data from these spreadsheets must be uploaded into your newly created tables before the database can be considered operational.

Regions

  • ID: 1, Abbreviation: NAR, Name: North America
  • ID: 2, Abbreviation: CALA, Name: Central and Latin America
  • ID: 3, Abbreviation: APAC, Name: Asia and Pacific
  • ID: 4, Abbreviation: EMEA, Name: Europe, Middle East, and Africa

Countries

  • ID: 1, Name: United States, Weekly Hours: 40, Holidays: 10, Vacation Days: 15, RegionID: 1
  • ID: 2, Name: Canada, Weekly Hours: 40, Holidays: 10, Vacation Days: 15, RegionID: 1
  • ID: 3, Name: United Kingdom, Weekly Hours: 40, Holidays: 8, Vacation Days: 20, RegionID: 4
  • ID: 4, Name: France, Weekly Hours: 35, Holidays: 8, Vacation Days: 20, RegionID: 4
  • ID: 5, Name: Ireland, Weekly Hours: 35, Holidays: 8, Vacation Days: 20, RegionID: 4
  • ID: 6, Name: Italy, Weekly Hours: 35, Holidays: 8, Vacation Days: 20, RegionID: 4
  • ID: 7, Name: Thailand, Weekly Hours: 40, Holidays: 13, Vacation Days: 15, RegionID: 3
  • ID: 8, Name: Singapore, Weekly Hours: 40, Holidays: 13, Vacation Days: 15, RegionID: 3
  • ID: 9, Name: Panama, Weekly Hours: 40, Holidays: 10, Vacation Days: 15, RegionID: 2

Benefit Types

  • ID: 1, Name: Vacation
  • ID: 2, Name: Holiday
  • ID: 3, Name: Jury Duty
  • ID: 4, Name: Maternity Leave
  • ID: 5, Name: Paternity Leave
  • ID: 6, Name: Military Duty

Contact Types

  • ID: 1, Name: Systems Engineer
  • ID: 2, Name: Sales
  • ID: 3, Name: Billing

Contract Types

  • ID: 1, Name: Maintenance
  • ID: 2, Name: Fixed Price
  • ID: 3, Name: License
  • ID: 4, Name: Time and Materials

Clients

  • ID: 1, Legal Name: BMA, Common Name: British Mobile, Addr1: 130 Wake Dr., City: Wake, State: NC, Zip: 24539, CountryID: 1
  • ID: 2, Legal Name: FT, Common Name: France Mobile, Addr1: 123 East St., Suite #2, Paris, Zip: 45678, CountryID: 4
  • ID: 3, Legal Name: IBC, Common Name: IBC, Addr1: 456 Main, Johor, Zip: 78945, CountryID: 8
  • ID: 4, Legal Name: MTM, Common Name: MTM, Addr1: 6789 First St., Mead, Zip: 45678, CountryID: 9
  • ID: 5, Legal Name: BT, Common Name: Britain Tele, Addr1: 98769 Park St., Level 3, London, Zip: 48695, CountryID: 4

Contracts

  • ID: 1, Desc: Work Order, Type: Maintenance, Client: FT
  • ID: 2, Desc: Work Order, Type: Time & Materials, Client: BT
  • ID: 3, Desc: Work Order, Type: Fixed Price, Client: IBC
  • ID: 4, Desc: Work Order, Type: Maintenance, Client: IBC
  • ID: 5, Desc: Work Order, Type: Fixed Price, Client: MTM
  • ID: 6, Desc: Work Order, Type: Time & Materials, Client: FT

Contacts

  • ID: 1, First: Bugg, Last: Bunny, Addr1: 123 Looney, Addr2: NoWhere, City: AK, Zip: 45678, CountryID: 1, Type: SysEng
  • ID: 2, First: Elmer, Last: Fudd, Addr1: 789 Park Pl., Apt 3, Skyville, NM, Zip: 45678, CountryID: 1, Type: Billing
  • ID: 3, First: Daffy, Last: Duck, Addr1: 45678 One St., Norwood, Zip: 45678, CountryID: 4, Type: Sales
  • ID: 4, First: Darth, Last: Vader, Addr1: 456 Two St., Towns, Zip: 47896, CountryID: 4, Type: Sales
  • ID: 5, First: Luke, Last: Sky, Addr1: #4 Tatooine, Paris, Zip: 45678, CountryID: 4, Type: Billing
  • ID: 6, First: Princess, Last: Lea, Addr1: 723 Coruscant, Rome, Zip: 45678, CountryID: 4, Type: SysEng
  • ID: 7, First: John, Last: Doe, Addr1: 987 Main St., Paris, Zip: 78945, CountryID: 4, Type: SysEng
  • ID: 8, First: Jane, Last: Doe, Addr1: 7658 Oak Ln., Crue, Zip: 45678, CountryID: 1, Type: SysEng

Contracts’ Contacts

  • Work Order 1, BT, Daffy Duck
  • Work Order 1, FT, John Doe, Jane Doe, Princess Lea
  • Work Order 2, FT, Elmer Fudd
  • Work Order 1, IBC, Buggs Bunny
  • Work Order 2, IBC, Luke Sky
  • Work Order 2, IBC, Darth Vader
  • Work Order 1, MTM, Daffy Duck

Employee Titles

  • ID: 1, Title: Consultant
  • ID: 2, Title: Analyst
  • ID: 3, Title: Director

Billing Rates

  • TitleID: 1, Level: 1, Rate: 50.00, Currency: USD
  • TitleID: 2, Level: 1, Rate: 60.00, Currency: USD
  • TitleID: 3, Level: 2, Rate: 70.00, Currency: USD

Employees

  • ID: 1, First: Matthew, Last: Smith, CountryID: 1, Email: [email protected], Salary: 45000, TitleID: 1, Level: 1
  • ID: 2, First: Mark, Last: Jones, CountryID: 1, Email: [email protected], Salary: 94000, TitleID: 3, Level: 1
  • ID: 3, First: Luke, Last: Rice, CountryID: 4, Email: [email protected], Salary: 65000, TitleID: 1, Level: 2
  • ID: 4, First: John, Last: Rich, CountryID: 5, Email: [email protected], Salary: 74000, TitleID: 1, Level: 3
  • ID: 5, First: James, Last: Doe, CountryID: 6, Email: [email protected], Salary: 40000, TitleID: 2, Level: 1
  • ID: 6, First: Peter, Last: Pride, CountryID: 3, Email: [email protected], Salary: 60000, TitleID: 2, Level: 2
  • ID: 7, First: Eric, Last: Potter, CountryID: 3, Email: eric.p[email protected], Salary: 81000, TitleID: 1, Level: 3
  • ID: 8, First: Paul, Last: Davis, CountryID: 1, Email: paul.d[email protected], Salary: 103000, TitleID: 3, Level: 2

Projects

  • ID: 1, Name: IBC – India, HourCapAmount: 120, ProjectManagerID: 2, ContractID: 3
  • ID: 2, Name: FT-Maint, HourCapAmount: 100, ProjectManagerID: 7, ContractID: 4
  • ID: 3, Name: BT – WO 1 Time, HourCapAmount: 270, ProjectManagerID: 4, ContractID: 5
  • ID: 4, Name: BT – WO1 Materials, HourCapAmount: 270, ProjectManagerID: 4, ContractID: 5
  • ID: 5, Name: IBC - WO1, HourCapAmount: 120, ProjectManagerID: 2, ContractID: 3
  • ID: 6, Name: IBC – WO2, HourCapAmount: 120, ProjectManagerID: 2, ContractID: 3
  • ID: 7, Name: MTM – WO1, HourCapAmount: 270, ProjectManagerID: 6, ContractID: 5
  • ID: 8, Name: FT – WO2 Time, HourCapAmount: 500, ProjectManagerID: 7, ContractID: 4
  • ID: 9, Name: FT –WO2 Materials, HourCapAmount: 500, ProjectManagerID: 7, ContractID: 4

Employee Project Assignments

  • Employee: John, Project: IBC-India, StartDate: 1/1/2013, EndDate: NULL
  • Employee: John, Project: FT-Maint, StartDate: 5/7/2013, EndDate: NULL
  • Employee: Daffy, Project: BT – WO 1 Materials, StartDate: 2/1/2013, EndDate: 4/30/2013
  • Employee: Smith, Project: FT-Maint, StartDate: 2/1