Question

In: Computer Science

We use the WMCRM database and here is the summary of the database schema (where schema...

We use the WMCRM database and here is the summary of the database schema (where schema is used in its meaning of a summary of the database structure):

VEHICLE (InventoryID, Model, VIN)

SALESPERSON (NickName, LastName, FirstName, HireDate, WageRate, CommissionRate, OfficePhone, EmailAddress, InventoryID)

CUSTOMER (CustomerID, LastName, FirstName, Address, City, State, ZIP, EmailAddress, NickName)

PHONE_NUMBER (CustomerID, PhoneNumber, PhoneType)

CONTACT(ContactID, CustomerID,ContactDate,ContactType,Remarks)

Where

InventoryID in SALESPERSON must exist in InventoryID in VEHICLE

NickName in CUSTOMER must exist in NickName in SALESPERSON

CustomerID in PHONE_NUMBER must exist in CustomerID in CUSTOMER

CustomerID in CONTACT must exist in CustomerID in CUSTOMER

To update the values we use UPDATE…SET statement as follows:

update customer

set LastName = 'Griffey'

where CustomerID = 3;

QUESTION 1: if you use update statement without WHERE clause, what can happen?

If we want to delete the record you use the following script:

delete

from customer

where CustomerID = 8;

QUESTION 2: If you use delete statement without WHERE clause, what can happen?

The SQL Drop Table Statement

The SQL DROP TABLE statement drops the table’s structure along with all of the table’s data. For example, to drop the contact table and all its data, you use the following SQL statement:

drop table contact

However, you can not drop customer table before drop contact table, because the SQL DROP TABLE statement does not work if the table contains or could contain values needed to fulfill referential integrity constraints.

QUESTION 3: Can you drop table salesperson? If yes, how do you do it? If no, why?

The SQL Alter Table Statement

To drop the customer table, you must first drop the phone_number table or at least delete the foreign key constraint PHONE_CUS_FK. This is one place where the ALTER TABLE command is useful. You use the SQL ALTER TABLE statement to add, modify, and drop columns and constraints. For example, you can use it to drop the PHONE_CUS_FK constraint with the statement:

alter table phone_number

drop constrain PHONE_CUS_FK;

After either dropping the phone_number table or the PHONE_CUS_FK foreign key constraint, you can then successfully drop the customer table.

Question 4: do you have another method to drop table salesperson?

Solutions

Expert Solution

Solution:

QUESTION 1: if you use update statement without WHERE clause, what can happen?

Answer : This will update all the records in the Customer table and set the last name of each customer to "'Griffey'".

QUESTION 2: If you use delete statement without WHERE clause, what can happen?

Answer : All the records will get deleted if we omit the WHERE condition.

QUESTION 3: Can you drop table salesperson? If yes, how do you do it? If no, why?

Answer: No, as there is a foreign key constraint existing. Following given constraint will prevent the dropping of the salesperson table as the nick name in CUSTOMER table must exist in the SALESPERSON Table.

Given : NickName in CUSTOMER must exist in NickName in SALESPERSON

Without dropping the CUSTOMER , the SALESPERSON cannot be dropped.

Question 4: do you have another method to drop table salesperson?

Answer : The SALESPERSON table can be dropped by first dropping the Foreign key Constraint. The foreign key constraint can be dropped by running the ALTER statement

alter table CUSTOMER

drop constrain SALESPERSON_CUS_FK;


Related Solutions

When is the conceptual schema of a database changed?- if we update data in the database...
When is the conceptual schema of a database changed?- if we update data in the database -if we alter the logical structure of the database -if we retrieve data from the database -if we alter the storage structure of the database Which of the following has the same meaning as the outer union? Group of answer choices -the left outer (natural) join -the right outer (natural) join -the full outer (natural) join -the inner (natural) join Assume {A, B} is...
The schema for the Academics database is as follows. Understanding this schema is necessary to answer...
The schema for the Academics database is as follows. Understanding this schema is necessary to answer the questions in Part B. DEPARTMENT(deptnum, descrip, instname, deptname, state, postcode) ACADEMIC(acnum, deptnum*, famname, givename, initials, title) PAPER(panum, title) AUTHOR(panum*, acnum*) FIELD(fieldnum, id, title) INTEREST(fieldnum*, acnum*, descrip) The semantics of most attributes are self-explanatory. For each relation, the primary key is underlined and any foreign keys are denoted by an asterisk (*). Some additional information for relations is given below: DEPARTMENT: Each academic department...
lab requires you to use Oracle VIEW to implement a virtual database on DBSEC schema, for...
lab requires you to use Oracle VIEW to implement a virtual database on DBSEC schema, for example, on CUSTOMER table. Your task is to develop a single SQL script that will perform all the following tasks: Table created for this assignment is listed below: create table CUSTOMER_VPD( SALES_REP_ID NUMBER(4), CUSTOMER_ID NUMBER(8) NOT NULL, CUSTOMER_SSN VARCHAR(9), FIRST_NAME VARCHAR(20), LAST_NAME VARCHAR(20), ADDR_LINE VARCHAR(40), CITY VARCHAR(30), STATE VARCHAR(30), ZIP_CODE VARCHAR(9), PHONE VARCHAR(15), EMAIL VARCHAR(80), CC_NUMBER VARCHAR(20), CREDIT_LIMIT NUMBER, GENDER CHAR(1), STATUS CHAR(1), COMMENTS...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various...
• Relational Schema Create a relational database schema consisting of the four relation schemas representing various entities recorded by a furniture company.   Write CREATE TABLE statements for the following four relation schemas. Define all necessary attributes, domains, and primary and foreign keys. Customer(CustomerID, Name, Address) FullOrder(OrderID, OrderDate, CustomerID) Request(OrderID, ProductID, Quantity) Product(ProductID, Description, Finish, Price) You should assume the following: Each CustomerID is a number with at most three digits, each OrderID is a number with at most five digits,...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes Express the following queries in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that a person likes Express the following queries...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in...
Consider the following database schema: LIKE(person, sport), PRACTICE(person, sport), where person and sport are keys in both tables. The table LIKE gives the sports a person likes, the table PRACTICE gives the sports a person practices. We assume that a person likes at least one sport and practices at least one sport. We assume also that a person does not like a sport if the sport is not listed among the sports that person likes. Express the following queries in...
[Q.4] Answer the following questions You are invited as a database architect to develop database schema...
[Q.4] Answer the following questions You are invited as a database architect to develop database schema for maintaining patient information for the NYU medical group (make necessary assumptions for the data requirements if needed). Each physician in the Lehman medical group is uniquely identified by physicianID o Each physician must have first name, and last name, and phone number Each patient is identified by patientID o Each patient must have first name, and last name, phone number, and insurance card...
Need an example of a database schema for an online or ecommerce store and an explanation...
Need an example of a database schema for an online or ecommerce store and an explanation of the how it functions
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench...
This refer to the “om” database (or Schema) that you will find in your MySQL Workbench program if you have run the sample database install script. Please save all of your answers in one script (.sql) or type all your answers into Notepad++ and submit them as a single .sql file. Please test your SQL statements in Workbench 1.       Using an INNER JOIN, select the order_id, order_date, shipped_date, fname, and customer_phone from the orders and customers tables. The fname is a...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT