Question

Sub-view/External Schema 4 Complaints and Responses Any consumer may file a complaint against a food establishment. A complai

Using SQL to design Sub-view/External Schema 1: Restaurants/Facilities
0 0
Add a comment Improve this question Transcribed image text
Answer #1

First, we need to identify the entities for our Schema.

As per the given information, complaint can be of different type, so we need a Complaint Type entity that will hold the types of complaints. Below will be the schema:

ComplaintType (ComplaintTypeID, ComplaintType) where ComplaintTypeID is the primary key.

We can create the SQL as:

CREATE TABLE ComplaintType(

     ComplaintTypeID VARCHAR(10) PRIMARY KEY,

     ComplaintType VARCHAR(50) NOT NULL

);

If it is regarding food borne illness, we need to track the illness type. So IllnessType would be next entity that will hold attributes as per the below schema

IllnessType (IllnessTypeID, CausativePathogen, IncubationTime, IllnessLength, CommonSymptoms)

We can create the SQL as:

CREATE TABLE IllnessType(

     IllnessTypeID VARCHAR(10) PRIMARY KEY,

     CausativePathogen VARCHAR(50),

     IncubationTime NUMBER NOT NULL,

     IllnessLength NUMBER NOT NULL,

     CommonSymptoms VARCHAR(100) NOT NULL

);

Next would be the Illness entity that will be as per the below schems

Illness (IllnessID, Illness, IllnessTypeID) where IllnessTypeID is the foreign key that refers to the above entity.

We can create the SQL as:

CREATE TABLE Illness(

     IllnessID VARCHAR(10) PRIMARY KEY,

     Illness VARCHAR(50) NOT NULL,

     IllnessTypeID VARCHAR(10) NOT NULL,

     FOREIGN KEY fk_IlTyp(IllnessTypeID)

          REFERENCES IllnessType(IllnessTypeID)

);

Now, the person who is filing the complaint would be the next entity called Complainant which will have the below schema.

Complainant (ComplainantID, Name, Address, Phone, email)

We can create the SQL as:

CREATE TABLE Complainant(

     ComplainantID VARCHAR(10) PRIMARY KEY,

     Name VARCHAR(30) NOT NULL,

     Address VARCHAR(100),

     Phone VARCHAR(15) NOT NULL,

     Email VARCHAR(20) NOT NULL

);

The complaint which is filed against the establishment will be the next entity called Facility which will have the below schema

Facility (FacilityID, FacilityName, Address)

We can create the SQL as:

CREATE TABLE Facility(

     FacilityID VARCHAR(10) PRIMARY KEY,

     FacilityName VARCHAR(20) NOT NULL,

     Address VARCHAR(100)

);

Now, the final entity would be the Complaint that will be files by the Complainant against the Facility. Below will be the schema

Complaint (ComplaintID, ComplaintDate, FacilityID, ComplainantID, ComplaintTypeID, IllnessID)

Where FacilityID is related to Facility entity, CompainantID is related to Complainant entity, ComplaintTypeID is related to ComplaintType and IllnessID is related to Illness entity and these all are represented here as foreign keys.

We can create the SQL as:

CREATE TABLE Complaint(

     ComplaintID VARCHAR(20) PRIMARY KEY,

     ComplaintDate DATE NOT NULL,

     FacilityID VARCHAR(10) NOT NULL,

     ComplainantID VARCHAR(10) NOT NULL,

     ComplaintTypeID VARCHAR(10) NOT NULL,

     IllnessID VARCHAR(10),

     FOREIGN KEY Comp_Fac(FacilityID)

          REFERENCES Facility(FacilityID),

     FOREIGN KEY Comp_Comp(ComplainantID)

          REFERENCES Complaint(ComplainantID),

     FOREIGN KEY Comp_CompType(ComplaintTypeID)

          REFERENCES ComplaintType(ComplaintTypeID),

     FOREIGN KEY Comp_Ill(IllnessID)

          REFERENCES Illness(IllnessID)

);

Let me know if you have any query.

Thanks!

Add a comment
Know the answer?
Add Answer to:
Using SQL to design Sub-view/External Schema 1: Restaurants/Facilities Sub-view/External Schema 4 Complaints and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • STEP 1: In your own words define problem employees and the categories they may fall into....

    STEP 1: In your own words define problem employees and the categories they may fall into. For the second or last paragraph provide your opinion on which employee type is the most difficult. DEFINITION : I think that "problem employees" are employees that either directly or indirectly hinder the organization's mission or vision, and break down into roughly four categories. In general, problem employees can be classified into two broad categories - employees creating problems for the organization and employees...

  • Read the following case: Answer the questions accordingly: PLEASE MAKE COPY PASTE AVAILABLE EEOC v. Management...

    Read the following case: Answer the questions accordingly: PLEASE MAKE COPY PASTE AVAILABLE EEOC v. Management Hospitality of Racine 666 F.3d 422 (7th Cir. 2012) OPINION BY DISTRICT JUDGE YOUNG: The Equal Employment Opportunity Commission ("EEOC") brought this action on behalf of two serv- ers, Katrina Shisler and Michelle Powell, who were em- ployed at an International House of Pancakes franchise in Racine, Wisconsin (the "Racine IHOP"), alleging that the servers were sexually harassed in violation of Title VII of...

  • Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first...

    Comprehensive Income Tax Course: Module 1 4. Randy turned 16 last year and had his first summer job. Even though his parents are claiming him as a dependent he wants to file a return in order to get his refund. He receives his W-2 and decides he can do his own return using form 1040-EZ. Which of the following information is not found on a Form W-2? a) The taxpayer’s Social Security number b) The taxpayer’s wages, tips and other...

  • Please read the article and answer about questions. You and the Law Business and law are...

    Please read the article and answer about questions. You and the Law Business and law are inseparable. For B-Money, the two predictably merged when he was negotiat- ing a deal for his tracks. At other times, the merger is unpredictable, like when your business faces an unexpected auto accident, product recall, or government regulation change. In either type of situation, when business owners know the law, they can better protect themselves and sometimes even avoid the problems completely. This chapter...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT