Write an SQL CREATE statement to create the structure of a table to store the following employee information empLastName, empFirstName, Dept (foreign key to department table), emp Address, empZip, empCity, empState. Use appropriate data types to reflect the data which will be stored in each attribute. Identify attributes which should not be null by using the correct SQL statements in the create statement
If you have any doubts, please give me comment...
CREATE TABLE employee(
empLastName VARCHAR(50) NOT NULL,
empFirstName VARCHAR(50) NOT NULL,
dept VARCHAR(5),
empAddress VARCHAR(50),
empZip CHAR(5),
empCity VARCHAR(50),
empState CHAR(2),
FOREIGN KEY(dept) REFERENCES department(dept_code)
);
Write an SQL CREATE statement to create the structure of a table to store the following...
DROP TABLE EMPLOYEE;
DROP TABLE JOB;
DROP TABLE EMP;
DROP TABLE EMP_1;
DROP TABLE EMP_2;
CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION
VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT
NULL,JOB_LAST_UPDATE DATE NOT NULL);
INSERT INTO JOB
VALUES('500','Programmer','35.75','20-Nov-2017');
INSERT INTO JOB VALUES('501','System
Analyst','96.75','20-Nov-2017');
INSERT INTO JOB VALUES('502','Database
Designer','125.00','24-Mar-2018');
CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME
VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL
CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS
NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE));
INSERT...
database and sql problme
THE QUESTIONS 3, 4,5 and 6 REFER TO THE RELATIONAL TABLES LISTED BELOW CREATE TABLE Department ( DECIMAL(5) VARCHAR(30) CHAR(5) DATE NOT NULL NOT NULL NOT NULL * Department number /*Department name * Department manager number */ /Manager start date DNumber DName Manager MSDate CONSTRAINT Department_PK PRIMARY KEY(DNumber) CONSTRAINT Department_CK UNIQUE(DName) CREATE TABLE DeptLocation DECIMAL(5) VARCHAR(50) NOT NULL NOT NULL DNumber * Department number */ * Department location */ Address CONSTRAINT DeptLocation_PK PRIMARY KEY(DNumber, Address) CONSTRAINT...
Use an INSERT INTO statement with a subquery containing a SQL string function to create user names for the volunteers based on their legal names and insert them into the table. +----------------------+ | Tables_in_volunteers | +----------------------+ | address | | email | | funds | | hours | | person | | phone | | users | +----------------------+ users legal names are in the address table user table is : CREATE TABLE USERS(volunteer_id INT NOT NULL, username VARCHAR(50), PRIMARY KEY...
Write a single SQL statement to create a new playlist called 'Background music'; and write another single SQL statement to associate the new playlist with the 10 longest duration tracks of jazz music from the Track table. CREATE TABLE MediaType ( MediaTypeID INTEGER PRIMARY KEY NOT NULL, Name TEXT ); CREATE TABLE Playlist ( PlaylistID INTEGER PRIMARY KEY NOT NULL, Name TEXT ); CREATE TABLE PlaylistTrack ( PlaylistID INTEGER NOT NULL, TrackID INTEGER NOT NULL, PRIMARY KEY (PlaylistID, TrackID), FOREIGN...
Write SQL Queries Given the following
tables
(7pts) Retrieve the names of employees and their
project name. If the employee never worked on a project, show the
names only the name, not the project name.
(7pts) Retrieve the names of employees who have worked
on the same project at a different location.
(7pts) Retrieve the names of employees who have worked
on more than two different projects.
(7pts) Retrieve the names of employees who manage more
than two employees.
CREATE...
Write SQL to create a table called City in your account. The schema of the table is listed below. You must define the data types and not null constraint (if needed) of every column and all the primary key and foreign key constraints for the table. No screenshot needed for this question. City (Name, Country, Population, Capital). Name: the name of the city. Text string with maximum 50 characters. Must not be null. Country: the name of the country where...
SQL queries and procedures TABLE: Employees Business Rules: EmployeeID is defined as the primary key. Address has been denormalized to include City and State for performance reasons. DeptNbr is a foreign key that references DeptNbr in the Department table Manager is a foreign key that references EmployeeID in the Employees table Data Structure: (EmployeeId, LastName, FirstName, Street, City, State, Zip, DateOfHire, DateOfBirth, JobTitle, Salary, DeptNbr(fk), Manager(fk)) TABLE: Department Business Rules: DeptNbr is defined as the primary key. Data Structure: (DeptNbr,...
Write the SQL statement to create a five-field table to contain sample student information. The constraints that need to be satisfied by the attributes of this table are as follows: the attribute First_Name is mandatory and can have up to 16 characters, the attribute Last_Name is mandatory and can have up to 16 characters, the attribute Date_Of_Birth is of type date is required, the StarID field identifies each student and is 8 characters long the GPA field is numeric that...
1. Write SQL CREATE Table statement to create the following table with Owner ID as a surrogate key. Owner ID is a surrogate key (starts at 1 and increments by 1) hint: IDENTITY (1, 1) is syntax for surrogate key. PET_OWNER (OwnerID, OwnerLastName, OwnerFirstName, OwnerPhone, OwnerEmail) You can try inserting some data into your tables too! 2. Write SQL CREATE Table statement to create the following table with Pet ID as a surrogate key. Pet ID is a surrogate key...
Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that begins with the letter 'M! CREATE TABLE Persons Personi int LastName varchar(80). FirstName varchar(80). Address varchar(125). State char(2) Given the following table structure, write the SQL code to display all the first and last names of the individuals that have a last name that does not contain the letter 'S: CREATE TABLE Persons PersonlDint,...