Question

In: Computer Science

Based on this code: CREATE TABLE DEPARTMENT ( DepartmentName Char(35) NOT NULL, BudgetCode Char(30) NOT NULL,...

Based on this code:

CREATE TABLE DEPARTMENT (

DepartmentName Char(35) NOT NULL,

BudgetCode Char(30) NOT NULL,

OfficeNumber Char(15) Not Null,

DepartmentPhone Char(12) NOT NULL,

CONSTRAINT DEPARTMENT_PK primary key(DepartmentName)

);

CREATE TABLE EMPLOYEE(

EmployeeNumber Int NOT NULL AUTO_INCREMENT,

FirstName Char(25) NOT NULL,

LastName Char(25) NOT NULL,

Department Char(35) NOT NULL DEFAULT 'Human Resources',

Position Char(35) NULL,

Supervisor Int NULL,

OfficePhone Char(12) NULL,

EmailAddress VarChar(100) NOT NULL UNIQUE,

CONSTRAINT EMPLOYEE_PK PRIMARY KEY(EmployeeNumber),

CONSTRAINT EMP_DEPART_FK FOREIGN KEY(Department)

REFERENCES DEPARTMENT(DepartmentName)

ON UPDATE CASCADE,

CONSTRAINT EMP_SUPER_FK FOREIGN KEY(Supervisor)

REFERENCES EMPLOYEE(EmployeeNumber)

);

ALTER TABLE EMPLOYEE AUTO_INCREMENT=1;

CREATE TABLE PROJECT(

ProjectID Int NOT NULL AUTO_INCREMENT,

ProjectName Char(50) NOT NULL,

Department Char(35) NOT NULL,

MaxHours Numeric(8,2) NOT NULL DEFAULT 100,

StartDate Date NULL,

EndDate Date NULL,

CONSTRAINT PROJECT_PK PRIMARY KEY(ProjectID),

CONSTRAINT PROJ_DEPART_FK FOREIGN KEY(Department)

REFERENCES DEPARTMENT(DepartmentName)

ON UPDATE CASCADE

);

ALTER TABLE PROJECT AUTO_INCREMENT=1000;

CREATE TABLE ASSIGNMENT (

ProjectID Int NOT NULL,

EmployeeNumber Int NOT NULL,

HoursWorked Numeric(6,2) NULL,

CONSTRAINT ASSIGNMENT_PK PRIMARY KEY(ProjectID, EmployeeNumber),

CONSTRAINT ASSIGN_PROJ_FK FOREIGN KEY(ProjectID)

REFERENCES PROJECT(ProjectID)

ON UPDATE NO ACTION

ON DELETE CASCADE,

CONSTRAINT ASSIGN_EMP_FK FOREIGN KEY(EmployeeNumber)

REFERENCES EMPLOYEE(EmployeeNumber)

ON UPDATE NO ACTION

How would I retrieve these commands?

Retrieve all the information for the assignments with hours worked less than 40.

Retrieve all the columns for employee(s) whose first name starts with M or J and ends with n

or e.

Retrieve all the columns for employee(s) whose first name is 5 letters.

Retrieve all the columns for employee(s) whose first name is 5 letters and en

ds with an a.

Retrieve all the columns for employee(s) whose first name is 5 letters and starts with a J and

ends with an a.

Solutions

Expert Solution

Retrieve all the information for the assignments with hours worked less than 40 :

select * from ASSIGNMENT where HoursWorked<40;

  • This SQL query return all the columns from ASSIGNMENT table

**********************************

Retrieve all the columns for employee(s) whose first name starts with M or J and ends with n or e :

select * from EMPLOYEE where FirstName like 'M%N' or FirstName like 'J%N' and
FirstName like 'M%E' or FirstName like 'J%E';

  • This SQL query is using Like clause and OR , AND operator to return the result

*******************************

Retrieve all the columns for employee(s) whose first name is 5 letters :

select * from EMPLOYEE where length(FirstName)=5;

  • This SQL query is using length() function to get the result

********************************

Retrieve all the columns for employee(s) whose first name is 5 letters and ends with an a :

select * from EMPLOYEE where length(FirstName)=5 and FirstName like '%a';

  • This SQL query is using length() function and like clause to get the result.

***********************************

Retrieve all the columns for employee(s) whose first name is 5 letters and starts with a J and ends with an a :

select * from EMPLOYEE where length(FirstName)=5 and FirstName like 'J%a';

  • This SQL query is using length() function and like clause to return the result.

Related Solutions

CREATE TABLE DRIVER( ENUM         DECIMAL(12) NOT NULL, LNUM         DECIMAL(8)    NOT NULL,...
CREATE TABLE DRIVER( ENUM         DECIMAL(12) NOT NULL, LNUM         DECIMAL(8)    NOT NULL, STATUS         VARCHAR(10) NOT NULL, CONSTRAINT DRIVER_PKEY PRIMARY KEY(ENUM), CONSTRAINT DRIVER_UNIQUE UNIQUE(LNUM), CONSTRAINT DRIVER_FKEY FOREIGN KEY(ENUM) REFERENCES EMPLOYEE(ENUM), CONSTRAINT DRIVER_STATUS CHECK ( STATUS IN ('AVAILABLE', 'BUSY', 'ON LEAVE')) ); (1)   Modify a consistency constraint of the sample database such that after a modification         it is possible to record in the database information about the drivers who are sick.   */ CREATE TABLE TRUCK(...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name...
In a Package called characterArray, ********JAVA CODE********** 1) Create a char array containing your full name and print it out. 2) Create an uninitialized char array and copy into it      the char array containing your full name and print it out. 3) Create a Character array and copy into it the char array containing      your full name and print it out. 4) Into the Character array, use toUpperCase() to copy the char array containing     your full name...
2 -​Create the code to generate a web page that contains a table. The table should...
2 -​Create the code to generate a web page that contains a table. The table should have 4 ​columns and 4 rows. Each cell should be 100 pixels wide by 100 pixels high. The border ​should be 2 ​pixels.
Create a table book_store with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_genre VARCHAR(255)...
Create a table book_store with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_genre VARCHAR(255) NOT NULL, Status VARCHAR(255) NOT NULL, PRIMARY KEY (Book_id) Create a table book with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_release integer, Book_price integer , Publisher Varchar(10), Book_genre VARCHAR(255) NOT NULL, PRIMARY KEY (Book_id) CREATE TABLE price_logs with columns id INT(11) NOT NULL AUTO_INCREMENT, Book_id VARCHAR(255) NOT NULL, Old_Book_price DOUBLE NOT NULL, New_Book_price DOUBLE NOT NULL, updated_at TIMESTAMP NOT NULL DEFAULT...
Create a table book_store with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_genre VARCHAR(255)...
Create a table book_store with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_genre VARCHAR(255) NOT NULL, Status VARCHAR(255) NOT NULL, PRIMARY KEY (Book_id) Create a table book with columns Book_id VARCHAR(255) NOT NULL, Book_Name VARCHAR(255) NOT NULL, Book_release integer, Book_price integer , Publisher Varchar(10), Book_genre VARCHAR(255) NOT NULL, PRIMARY KEY (Book_id) CREATE TABLE price_logs with columns id INT(11) NOT NULL AUTO_INCREMENT, Book_id VARCHAR(255) NOT NULL, Old_Book_price DOUBLE NOT NULL, New_Book_price DOUBLE NOT NULL, updated_at TIMESTAMP NOT NULL DEFAULT...
create a VHDL program for the Truth Table below. Please make sure to create your code...
create a VHDL program for the Truth Table below. Please make sure to create your code for the simplified circuit. A B C Z 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 1 0 1 1 1 1 0
Given the declaration                         char table[7][9];              &nb
Given the declaration                         char table[7][9];                             which of the following stores the character 'B' into the fifth row and second column of the array?             A) table[5] = 'B';             B)   table[2][5] = 'B';             C)   table[5][2] = 'B';             D) table[1][4] = 'B';             E)   table[4][1] = 'B'; This program fragment is intended to zero out a two-dimensional array: int arr[10][20];             int i, j;                         for (i = 0; i < 10; i++)...
Test the null hypothesis H0:μ=3.8against the alternative hypothesis HA:μ≠3.8, based on a random sample of 35...
Test the null hypothesis H0:μ=3.8against the alternative hypothesis HA:μ≠3.8, based on a random sample of 35 observations drawn from a normally distributed population with x¯=4 and σ=0.89. a) What is the value of the test statistic? Round your response to at least 3 decimal places.     b) What is the appropriate p-value? Round your response to at least 3 decimal places.     c) Is the null hypothesis rejected at: i) the 5% level of significance?      NoYesClick for List   ii) the...
CREATE TABLE youtubevideos( url VARCHAR(150), title VARCHAR(50), description VARCHAR(200), comid INTEGER NOT NULL, postuserVARCHAR(50) NOT NULL,...
CREATE TABLE youtubevideos( url VARCHAR(150), title VARCHAR(50), description VARCHAR(200), comid INTEGER NOT NULL, postuserVARCHAR(50) NOT NULL, postdate DATE, PRIMARY KEY (email), FOREIGN KEY (comid) REFERENCES Comedians(comid), FOREIGN KEY (postuser) REFERENCES Users(email)); CREATE TABLE Users( email VARCHAR(50), password VARCHAR(50), firstname VARCHAR(50), lastname VARCHAR(50), gender CHAR(1), age INTEGER, PRIMARY KEY (email)); CREATE TABLE Comedians( comid INTEGER, firstname VARCHAR(50), lastname VARCHAR(50), birthday DATE, VARCHAR(50), PRIMARY KEY(comid)); CREATE TABLE Reviews( reviewid INTEGER NOT NULL AUTO_INCREMENT, remark VARCHAR(100), rating CHAR(1), //P.F.G.E author VARCHAR(50) NOT NULL,...
R code Need assistance in getting this R code to run variables (Process) char ( Age)...
R code Need assistance in getting this R code to run variables (Process) char ( Age) char tmp <- expand.grid(Process = unique(words$Process),Age =unique(words$Age)) X <- model.matrix(~ factor(Process):factor(Age), data = tmp) glht(mod, linfct = X)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT