
Concept explainers
how can I CREATE Two SQL CREATE VIEW Statements. One of the CREATE VIEW Statements must use two joined tables.
- Use the two created VIEWS in two different SELECT Statements. One created VIEW per SELECT Statement.
- Use the SHOW FULL TABLES Statement to list the stored VIEWS in the
Database
- Relational schema
The primary key is bold and the foreign key is italic
Region(regionID, regionName, director)
StateOfRegion(stateCode, stateName, statePopulation, RegionID)
Store(StoreID, phone, manager, address, regionID)
Employee(empID, storeID, empName, hireDate, birthDate, socSecNum)
Supplier(supplierID, SupplierName, contact, email, phone)
StoreSupplier(storeID, supplierID, startDate)
- Meta dataThe metdata for each table from the given ER diagram is as below
Table Name |
Attribute |
Data Type |
Constraint |
Region |
|
|
|
|
regionID |
INT |
PK |
|
regionName |
VARCHAR |
NOT NULL |
|
director |
VARCHAR |
|
|
|
|
|
StateOfRegion |
|
|
|
|
stateCode |
CHAR(2) |
PK |
|
stateName |
VARCHAR |
Not NULL |
|
statePopulation |
double |
|
|
regionID |
int |
FK Region(RegionID) |
|
|
|
|
Store |
|
|
|
|
storeID |
int |
PK |
|
phone |
VARCHAR |
Not Null |
|
manager |
int |
Not Null |
|
address |
VARCHAR |
Not Null |
|
regionID |
int |
FK Region(RegionID) |
|
|
|
|
Employee |
|
|
|
|
empID |
Int |
PK |
|
storeID |
int |
FK Store(StoreID) |
|
empName |
VARCHAR |
Not Null |
|
hireDate |
Date |
Not Null |
|
birthDate |
Date |
|
|
socSecNum |
Int |
|
|
|
|
|
Supplier |
|
|
|
|
supplierID |
INT |
PK |
|
supplierName |
VARCHAR |
Not null |
|
contact |
VARCHAR |
Not null |
|
|
VARCHAR |
Not null |
|
phone |
VARCHAR |
Not null |
|
|
|
|
StoreSupplier |
|
|
|
|
storeID |
Int |
PK, FK store(StoreID) |
|
supplierID |
int |
PK, FK Supplier(SupplierID) |
|
startDate |
Date |
Not null |
- The create table script:
DROP DATABASE IF EXISTS RegionStore;
CREATE DATABASE RegionStore;
USE RegionStore;
CREATE TABLE Region
(
regionID VARCHAR(10),
regionName VARCHAR(50),
supervisor VARCHAR(50),
CONSTRAINT PRIMARY KEY (regionID)
);
CREATE TABLE Store
(
storeID VARCHAR (10),
storeAddress VARCHAR (50),
phone VARCHAR (10),
Manager VARCHAR (10),
regionID_FK VARCHAR (10),
CONSTRAINT PRIMARY KEY (storeID),
CONSTRAINT FOREIGN KEY (regionID_FK)
REFERENCES REGION (regionID)
);
CREATE TABLE Employee
(
empNum VARCHAR (10),
empName VARCHAR (50),
hireDate DATE,
birthDate Date,
socSecNum CHAR(9),
storeID_FK VARCHAR(10),
CONSTRAINT PRIMARY KEY (empNum),
CONSTRAINT FOREIGN KEY (storeID_FK)
REFERENCES Store(storeID)
);
CREATE TABLE Supplier
(
supplierID VARCHAR (10),
supplierName VARCHAR (50),
contact VARCHAR (50),
phone CHAR (10),
email VARCHAR (50),
CONSTRAINT PRIMARY KEY (supplierID)
);
CREATE TABLE Supplies
(
supplierID_FK VARCHAR (10),
storeID_FK VARCHAR (10),
startDate DATE,
CONSTRAINT PRIMARY KEY (supplierID_FK,storeID_FK )
);
CREATE TABLE StateOfRegion
(
stateCode CHAR(2),
stateName VARCHAR(50),
regionID_FK VARCHAR(10),
statePopulation INT,
CONSTRAINT PRIMARY KEY (stateCode),
CONSTRAINT FOREIGN KEY (regionID_FK )
REFERENCES REGION(regionID)
);
INSERT INTO region (regionID,regionName,supervisor)
VALUES ('001','Alabama','Henry');
INSERT INTO Region (regionID,regionName,supervisor)
VALUES ('003','wellington','katty');
INSERT INTO Region (regionID,regionName,supervisor)
VALUES ('004','hamilton','ross');
INSERT INTO Region (regionID,regionName,supervisor)
VALUES ('005','auckland','robert');


Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Create a table in SQL developer and name it as ‘MyCrush’. The table should consists of only three attributes as follows: Crush_ID which will be the primary key with the number length of .Crush_Name with the maximum character length of 30.Crush_Description with the maximum character length of 10.Insert exactly three records with the above given attributes. Crush_ID values should be 1, 2 and 3 for the three records. Crush_Description should be ‘Present’ for record 1, ‘Past’ for record 2 and ‘Childhood’ for record 3. If you don’t have any crush from your childhood to present, you can insert some random names. Hmm.. Seems Interesting!! It’s time to implement your programming skills using PL/SQL stored procedures and functions. Create another table called ‘MyDetails’ and should contain exactly four attributes as below: Student_ID,Student_Name ,Student_Term ,Student_GPA If you are not a Master’s student, let’s assume you are a student pursuing masters and taking four semesters or terms.…arrow_forward4. This question continues from Q3. (a) Write the insert SQL to populate the Zoom, BB, and the QR tables with the values given below. For each table, use only one insert to complete the insert task. The Duration column is initially empty. (b) Can you insert the ZOOM table first? Provide a reason according to the relational database theory if it is not possible. (c) Write a Delete SQL to remove student ‘M M’ from the BB table. If it is not possible to remove the row, provide a reason according to the relational database theory. You must not use SID in the SQL because only the name is given. (d) Write an Update DML that will compute and update the duration in minutesin the Zoom table. Show the updated table and the DML.arrow_forwarduse oracle sql developper or Oracle sql developper problem in picture the database CREATE TABLE MEMBERSHIP( MEM_NUM CHAR(3) CONSTRAINT MEMBER_MEM_NUM_PK PRIMARY KEY,MEM_FNAME VARCHAR(30) NOT NULL,MEM_LNAME VARCHAR(30) NOT NULL,MEM_STREET VARCHAR(15),MEM_CITY VARCHAR(10),MEM_STATE CHAR(2),MEM_ZIP CHAR(5),MEM_BALANCE NUMBER (2)); ALTER TABLE MEMBERSHIPMODIFY MEM_STREET VARCHAR(25);CREATE TABLE RENTAL( RENT_NUM CHAR(4) CONSTRAINT RENTAL_RENT_NUM_PK PRIMARY KEY,RENT_DATE DATE,MEM_NUM CHAR(3),CONSTRAINT RENTAL_MEM_NUM_FK FOREIGN KEY (MEM_NUM) REFERENCES MEMBERSHIP); CREATE TABLE PRICE(PRICE_CODE CHAR(1) CONSTRAINT PRICE_PRICE_CODE_PK PRIMARY KEY,PRICE_DESC VARCHAR(20),PRICE_RENTFEE NUMBER (3,1),PRICE_DAILYATFEE NUMBER(3,1)); CREATE TABLE MOVIE(MOVIE_NUM CHAR(4) CONSTRAINT MOVIE_MOVIE_NUM_PK PRIMARY KEY,MOVIE_NAME VARCHAR(30) NOT NULL,MOVIE_YEAR CHAR(4),MOVIE_COST NUMBER(5,2),MOVIE_GENRE VARCHAR(15),PRICE_CODE CHAR(1),CONSTRAINT MOVIE_PRICE_CODE_FK FOREIGN KEY (PRICE_CODE) REFERENCES…arrow_forward
- Prepare a MySQL script that creates your database, tables, and inserts a small sampling of madeupdata. Test it out in MySQL before submission For the below diagram write the SQL queriesarrow_forwardUSE this part to write SQL statements at the bottom questions 1-11 Branch(branch_id:integer, branch_name:varchar(50), branch_location:varchar(40), money_on_hand:numeric(15,2) create table Branch (branch_id integer, branch_name varchar(50), branch_location varchar(40), money_on_hand numeric(15,2), primary key (branch_id)); Loan(loan_number:integer, branch_id:integer, amount:numeric(8,2)) foreign key branch_id references Branch(branch_id) create table Loan (loan_number integer, branch_id integer, amount numeric(8,2), primary key (loan_number), foreign key (branch_id) references Branch (branch_id)); Customer(customer_id:integer, customer_last_name:varchar(35),customer_first_name:varchar(25), customer_street:varchar(30),…arrow_forwardI want to write the SQL to create the tables for the ERD attached, but I also want to add this to the tables: rental date, due date, and return date so that I can support overdue queries. I also want it so each table has primary keys and foreign keys. I want it so the tables have at least 4 rows of data. How can I do this? Thank you for your help as I learn more about SQL and table creation.arrow_forward
- Topic: Database Software: SQLite Schema Table: CREATE TABLE name_basics (nconst VARCHAR(45) NOT NULL, primaryName VARCHAR(45) NULL, birthYear YEAR(4) NULL, deathYear YEAR(4) NULL, age INT NULL, movieNum INT NULL, PRIMARY KEY (nconst)); CREATE TABLE title_episode (episodeID VARCHAR(45) NOT NULL,parentTconst VARCHAR(45) NULL, seasonNumber INT NULL,episodeNumber INT NULL, PRIMARY KEY (episodeID), CONSTRAINT parentTconst FOREIGN KEY (parentTconst) REFERENCES title_basics (tconst) ON DELETE NO ACTION ON UPDATE NO ACTION); CREATE TABLE title_principals (tconst VARCHAR(45) NOT NULL, ordering INT NULL, nconst VARCHAR(45) NULL, category VARCHAR(45) NULL,job VARCHAR(45) NULL, characters VARCHAR(45) NOT NULL, PRIMARY KEY (tconst, characters), CONSTRAINT nconst FOREIGN KEY (nconst)REFERENCES name_basics (nconst) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT tconst FOREIGN KEY (tconst) REFERENCES title_basics (tconst) ON DELETE NO ACTION ON UPDATE NO ACTION); CREATE TABLE title_ratings…arrow_forwardBased on the ERD below, write the SQL statement to change the job description of “Database Designer” to “Database Developer”. After completing this task examine the results with a select statement. (Hint: Use an Update Statement.)arrow_forwardBy skipping columns that don't fit certain requirements, a select operation may drastically shrink a table's footprint in a relational database.Should I believe it or not?arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





