Having trouble creating SQL data base. Need help trying to correct the following data so that it will run...
CREATE TABLE CUSTOMER_T
(Customer_ID VARCHAR2(10),
CUSTOMER_NAME VARCHAR2(50),
CUSTOMER_STREET VARCHAR2(50),
CUSTOMER_CITY VARCHAR2(25),
CUSTOMER_STATE VARCHAR2(2),
CUSTOMER_POSTAL_CODE VARCHAR2(9),
CUSTOMER_TYPE VARCHAR2(20),
LOCATION_ID VARCHAR2(15),
CONSTRAINT CUSTOMER_PK PRIMARY KEY (CUSTOMER_ID),
CONSTRAINT CUSTOMER_FK FOREIGN KEY(LOCATION_ID) REFERENCES
LOCATION_T (LOCATION_ID));
CREATE TABLE LOCATION_T
(LOCATION_ID VARCHAR2(15),
LOCATION_NAME VARCHAR2(30),
LOCATION_COUNTRY VARCHAR2(30),
CONSTRAINT LOCATION_PK PRIMARY KEY (LOCATION_ID),
CONSTRAINT LOCATION_FK FOREIGN KEY(RATE_ID) REFERENCES
LOCATION(LOCATION_ID));
CREATE TABLE RATE_T
(RATE_ID VARCHAR2(15),
RATE_CLASS VARCHAR2(20),
RATE_PER_kwh NUMBER(10,2),
CONSTRAINT RATE_ID PRIMARY KEY (RATE_ID));
CREATE TABLE CUSTOMER_LOCATION_T
(CUSTOMER_ID VARCHAR2(25) NOT NULL,
LOCATION_ID VARHAR2(15) NOT NULL,
CONSTRAINT FOREIGN KEY(CUSTOMER_ID) REFERENCES
CUSTOMER(CUSTOMER_ID),
CONSTRAINT customer_Location_fk FOREGIN KEY(LOCATION_ID) REFERENCES
LOCATION(LOCATION_ID));
CREATE TABLE LOCATION_RATE_T
(LOCATION_ID VARCHAR2(15) NOT NULL,
RATE_ID VARCHAR2(15) NOT NULL,
TIME_OF_DAY TIME NOT NULL,
CONSTRAINT FOREIGN KEY(LOCATION_ID) REFERENCES
LOCATION(LOCATION_ID),
CONSTRAINT FOREIGN KEY(RATE_ID) REFERENCES RATE(RATE_ID);
In table LOCATION_T there is no attribute named RATE_ID so it is
been removed, whole LOCATION_FK has been removed, as no FOREIGN KEY
is required there.
Next in table CUSTOMER_LOCATION_T "CONSTRAINT " and "CONSTRAINT
customer_Location_fk " is removed along with spelling of FOREIGN is
also corrected.
Similarly "CONSTRAINT " is also removed from table LOCATION_RATE_T
and in the end bracket is added before ;
CREATE TABLE CUSTOMER_T
(CUSTOMER_ID VARCHAR2(10),
CUSTOMER_NAME VARCHAR2(50),
CUSTOMER_STREET VARCHAR2(50),
CUSTOMER_CITY VARCHAR2(25),
CUSTOMER_STATE VARCHAR2(2),
CUSTOMER_POSTAL_CODE VARCHAR2(9),
CUSTOMER_TYPE VARCHAR2(20),
LOCATION_ID VARCHAR2(15),
CONSTRAINT CUSTOMER_PK PRIMARY KEY (CUSTOMER_ID),
CONSTRAINT CUSTOMER_FK FOREIGN KEY(LOCATION_ID) REFERENCES
LOCATION(LOCATION_ID));
CREATE TABLE LOCATION_T
(LOCATION_ID VARCHAR2(15),
LOCATION_NAME VARCHAR2(30),
LOCATION_COUNTRY VARCHAR2(30),
CONSTRAINT LOCATION_PK PRIMARY KEY (LOCATION_ID));
CREATE TABLE RATE_T
(RATE_ID VARCHAR2(15),
RATE_CLASS VARCHAR2(20),
RATE_PER_kwh NUMBER(10,2),
CONSTRAINT RATE_ID PRIMARY KEY (RATE_ID));
CREATE TABLE CUSTOMER_LOCATION_T
(CUSTOMER_ID VARCHAR2(25) NOT NULL,
LOCATION_ID VARCHAR2(15) NOT NULL,
FOREIGN KEY(CUSTOMER_ID) REFERENCES CUSTOMER(CUSTOMER_ID),
FOREIGN KEY(LOCATION_ID) REFERENCES LOCATION(LOCATION_ID));
CREATE TABLE LOCATION_RATE_T
(LOCATION_ID VARCHAR2(15) NOT NULL,
RATE_ID VARCHAR2(15) NOT NULL,
TIME_OF_DAY DATE NOT NULL,
FOREIGN KEY(LOCATION_ID) REFERENCES LOCATION(LOCATION_ID),
FOREIGN KEY(RATE_ID) REFERENCES RATE(RATE_ID));
Having trouble creating SQL data base. Need help trying to correct the following data so that...
For each city, list number of customers from the city, who have placed order(s). Cities are listed in ascending alphabetical order. Use equal join for this query. CREATE TABLE customer ( cust_id number(11,0) not null, cust_name varchar2(25) not null, street varchar2(30), city varchar2(20), state varchar2(2), zipcode varchar2(5), CONSTRAINT customer_pk PRIMARY KEY (cust_id) ); CREATE TABLE ordertable ( order_id number(11,0) not null, order_date date, cust_id number(11,0), CONSTRAINT order_pk PRIMARY KEY (order_id), CONSTRAINT order_fk FOREIGN KEY (cust_id) REFERENCES customer (cust_id)); CREATE TABLE...
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...
I try to insert data into one of the table causes but I got an error message, I don't know how to resolve this SQL> CREATE TABLE Causes(cid NUMBER(5) PRIMARY KEY, name VARCHAR2(20) REFERENCES Signup, problem VARCHAR2(256), location VARCHAR2(200),fund NUMBER(30)); Table created. SQL> CREATE TABLE Causes(cid NUMBER(5) PRIMARY KEY, name VARCHAR2(20) REFERENCES Signup, problem VARCHAR2(256), location VARCHAR2(200),fund NUMBER(30)); Table created. SQL> describe Signup; Name Null? Type ----------------------------------------- -------- ---------------------------- USERNAME NOT NULL VARCHAR2(50) PASSWORD VARCHAR2(50) NAME NOT NULL VARCHAR2(100) AGE ...
/* I am executing following SQL statement for the below code but I am getting error. Pls, upload screenshot after running it. SQL Statement: SELECT OfferNo, CourseNo FROM Offering WHERE OfferTerm = 'Sum' AND OfferYear = 2012 AND FacSSN IS NULL; */ CREATE TABLE STUDENT( StdSSN INT NOT NULL PRIMARY KEY, StdFName VARCHAR2(50), StdLName VARCHAR2(50), StdCity VARCHAR2(50), StdState VARCHAR2(2), StdZip VARCHAR2(10), StdMajor VARCHAR2(15), StdYear VARCHAR2(20) ); CREATE TABLE FACULTY( FacSSN INTEGER NOT NULL PRIMARY KEY, FacFName VARCHAR(50), FacLName VARCHAR(50), FacCity...
MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects 2.List the project with the most hours SCRIPT TO BUILD DATABASE create table department ( dept_ID int not null , dept_name char(50) NOT NULL, manager_ID int not null, manager_start_date date not null, constraint Dept_PK primary key (dept_ID), constraint D_Name_AK unique (dept_name) ); insert into department values(1,'abc',1,'2019-01-08'); insert into department values(2,'abc2',2,'2019-01-08'); insert into department values(3,'abc3',2,'2019-01-08'); insert into department values(4,'abc4',2,'2019-01-08'); /*project table done*/ create table project...
SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...
I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...
I am trying to delete these tables from my data base and I keep getting: "mysql> DROP TABLE Courses; ERROR 1217 (23000): Cannot delete or update a parent row: a foreign key constraint fails" I am using the command DROP TABLE Courses; Below is my sql file use sdev300; // Create a student table CREATE TABLE Students ( PSUsername varchar(30) primary key, FirstName varchar(30), LastName varchar(30), EMail varchar(60) ); CREATE TABLE Courses( CourseID int primary key, CourseDisc varchar(4), CourseNum varchar(4),...
Write an SQL query to return the users who posted the most number of jokes on 1/1/2019. Database: create table User( userid varchar(30) not null, password varchar(30), firstname varchar(30), lastname varchar(50), email varchar(50), gender char(1), age integer, banned boolean, primary key(userid), unique(email)); create table MyFriends( userid varchar(30), friendid varchar(30), primary key(userid,friendid), foreign key(userid) references User, foreign key(friendid) references User(userid)); Create table Jokes( Jokeid integer, title varchar(100), description varchar(255), authorid varchar(30) not null, primary key(jokeid), posttime Datetime, foreign key(authorid) references User(userid));...
Define an SQL view JokesNum that gives the number of jokes each user posts on each day. Database: create table User( userid varchar(30) not null, password varchar(30), firstname varchar(30), lastname varchar(50), email varchar(50), gender char(1), age integer, banned boolean, primary key(userid), unique(email)); create table MyFriends( userid varchar(30), friendid varchar(30), primary key(userid,friendid), foreign key(userid) references User, foreign key(friendid) references User(userid)); Create table Jokes( Jokeid integer, title varchar(100), description varchar(255), authorid varchar(30) not null, primary key(jokeid), posttime Datetime, foreign key(authorid) references User(userid));...