Create a new database in sql server and run

Assignment Help PL-SQL Programming
Reference no: EM13316893

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),
TitleIDint,
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)


Attachment:- CMS-Project-Phase-II-Instructions-3-.docx

Reference no: EM13316893

Questions Cloud

Determine what is the most probable length : a line was measured five times, the readings were: 100.08, 100.51, 100.32, 100.16, 100.22. what is the error. What is the most probable length.
Calculate the change in internal energy of the gas : An ideal gas expands isothermally, performing 4.36 multiplied by 103 J of work in the process. Calculate the change in internal energy of the gas
What is the volume of the tank : A storage tank at STP contains 19.5 kg of nitrogen (N2). What is the volume of the tank
Estimate the pressure exerted on a floor : Estimate the pressure exerted on a floor by the one pointed chair leg (50 kg on all four legs) of area = 0.08 cm2
Create a new database in sql server and run : 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 con..
Graph of the production possibilities frontiers : What is the graph of the production possibilities frontiers for the American and Japanese economies if American worker can produce 10 tons of grain a year and Japanese worker can produce 5 tons a year?
Find the velocities of the ball : A 200 gram ball, moving at 6.0 m/s, is catching up and colliding elastically witha 600 gram ball that is moving along the same line
Basic roles of the government in an economy : What do you think are the basic roles of the government in an economy? Why do you think that these roles of the government are justified and the government plays a vital role in the economy in terms of allocation, redistribution and stabilization.
What would be emissions of sulfur dioxide from having burned : if a residential space heater burns anthricite coal having a sulfur of 2.85% what would be the emissions of sulfur dioxide from having burned 900 ib of this coal. use ap-42 table 1.2-1 sulfur dioxide emission=[SO2] pounds.

Reviews

Write a Review

PL-SQL Programming Questions & Answers

  Produce a diagram showing schema

Produce a diagram showing schema and the partial and transitive dependencies in your 1NF. b. Produce a diagram showing table schema and any transitive dependencies in your 2NF

  Write a perl subroutine for temperature conversion

Write a perl subroutine for temperature conversion named 'convert_temp'. It should be able to handle both Fahrenheit to Celsius conversions as well as Celsius to Fahrenheit conversions.

  Select statement to return one row

Write a SELECT statement that returns one row for each general ledger account number which contains three columns.

  Write a perl subroutine for temperature conversion

Write a perl subroutine for temperature conversion named ' convert_temp '. It should be able to handle both Fahrenheit to Celsius conversions as well as Celsius to Fahrenheit conversions.

  Give me a list of all the proposed prices

Give me a list of all the proposed prices for the next year from the l_foods table.  Sort your results by proposed_price.  (Note that proposed price, is price + price_increase.)

  Write programme in oracle to make employee table

List the employee_id and employee_name of the employees form the l_employees table with the top 4 credit limits.

  Create student sorting table

Student.txt in the attachment contains the roster of a class. Each student object has the following fields: student id, last name, first name, academic level.Create a RosterClass to store the student database in vector.

  Sql statements to create tables using sql ddl statements

Write SQL statements to create the above tables using SQL DDL statements. Write an INSERT statement to add two new records to each table.

  Write the sql ddl to create the database

Write a command that will remove the Jones that lives in Orange from the Customer table .Write the SQL DDL to create the database that contains each of the relations shown in the above ERD.

  Provide four queries to answer questions asked by end users

Explain how you will go about developing this database. Provide at least four queries that answer some of the questions asked by the end users.

  Write a script that declares a variable

Write a script that declares a variable and sets it to the count of all products in the Products table. If the count is greater than or equal to 7, the script should display a message that says,

  How does the order of joins in an sql statement

How does the order of joins in an SQL statement affect the performance of the join and what can the DBA do to determine the preferred order of joins for an SQL statement that includes the join of at least three tables?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd