Question

Sample data for these tables are shown in Figures 3-26 and 3-27. For each SQL statement you write, show the results based onFIGURE 3-26 PET_OWNER Data Owner ID 1 2 Owner LastName OwnerFirstName Owner Phone Downs Marsha 555-537-8765 James Richard 5553.11 Write the required SQL statements to create the PET_2 table. 3.12 Is PET or PET_2 a better design? Explain your rational

0 0
Add a comment Improve this question Transcribed image text
Answer #1

3.7)

Table Creation:

create table PET_OWNER (OwnerID INTEGER AUTO_INCREMENT PRIMARY KEY,OwnerLastName CHAR(10),OwnerFirstName CHAR(10),OwnerPhone VARCHAR(15),OwnerEmail VARCHAR(30));

Insert Data into Table:

INSERT INTO PET_OWNER VALUES (1,"Downs","Marsha","555-537-8765","[email protected]"),(2,"James","Richard","555-537-7654","[email protected]"),(3,"Frier","Liz","555-537-6543","[email protected]"),(4,"Trent","Miles",NULL,"[email protected]");

Output Screenshot:

mysql> create table PET_OWNER (OwnerID INTEGER AUTO_INCREMENT PRIMARY KEY, OwnerLastName CHAR (10), OwnerFirstName CHAR(10),

3.8)

Create Table:

create table PET(PetID integer primary key, PetName char(10),PetType char(5),PetBreed varchar(20),PetDOB varchar(15),OwnerID integer);

Insert Date into Table:

insert into PET VALUES(1,"King","Dog","Std.Poodle","27-Feb-16",1),(2,"Teddy","Cat","Cashmere","01-Feb-17",2),(3,"Fido","Dog","Std.Poodle","17-Jul-15",1),(4,"AJ","Dog","Collie Mix","05-May-16",3),(5,"Cedro","Cat","Unknown","06-Jun-14",2),(6,"Wooley","Cat","Unknown",NULL,2),(7,"Buster","Dog","Border Collie","11-Dec-13",4);

Output Screenshot:

mysql> create table PET(PetID integer primary key, PetName char(10), PetType char(5), PetBreed varchar(20), PetDOB varchar(15

Why not make every column NOT NULL?

Because in PetDOB Column there is no value so we considered that as NULL value.

3.9)

ALTER TABLE PET ADD FOREIGN KEY (OwnerID) REFERENCES PET_OWNER (OwnerID);

3.10)

ALTER TABLE PET ADD FOREIGN KEY (OwnerID) REFERENCES PET_OWNER (OwnerID) ON DELETE CASCADE;

3.11)

Create Table:

create table PET_2 (Pet_Name char(20) primary key,PetType char(5),PetBreed varchar(20),PetDOB varchar(15),OwnerID integer references PET_OWNER (OwnerID));

Output Screenshot:

mysql> create table PET_2 (Pet_Name char(20) primary key, PetType char(5), PetBreed varchar(20 ), PetDOB varchar(15), OwnerID

3.12) Answer:

PET table is a better design. because it have more information.

Add a comment
Know the answer?
Add Answer to:
Sample data for these tables are shown in Figures 3-26 and 3-27. For each SQL statement...
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
  • 1. Write SQL CREATE Table statement to create the following table with Owner ID as a...

    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...

  • The figure below shows a list used by a veterinary office. Refer to the list and...

    The figure below shows a list used by a veterinary office. Refer to the list and answer the questions below. 1. G H OwnerEmail Marsha [email protected] Richaed [email protected] Marha [email protected] Lic [email protected] Richard [email protected] Richard [email protected] Mies [email protected] Hilay [email protected] PerD08 27-Feb-12 Downs 1Feb-11 James 17-Jul-13 Downs 5-May-13 Frer 6Jun-10 James Ownerl astName OwnerFirstName Marsha Richard Marsha Liz Richard Richard Miles Hilary OwnerPhone 201-823-5467 201-735-9812 201-823-5467 201-823-6578 201-735-9812 201-735-9812 201-634-7065 210-634-2345 PetType PetName 2 King 3 Teddy 4 Fido 5...

  • write an SQL statement to list all the people in the Owner table, along with their...

    write an SQL statement to list all the people in the Owner table, along with their pets' names if any. That is, for each pet an owner has, there will be a record containing the owner and the pet's name. For any owner contained in the Owner table, the output should always contain the owner's record even if no pets are associated with this owner. Hint: outer join/s may be needed. -- DROP TABLE PetAndOwner, Pet, PetType, Owner; CREATE TABLE...

  • (SQL) Write DDL statements to create the tables below and use appropriate data types for the...

    (SQL) Write DDL statements to create the tables below and use appropriate data types for the attributes.Relational database schema: Teacher = [CourseN, Quarter,TeacherName] Course = [CourseN,CourseName, Nunit) LocationNTime = [CourseN, Quarter , DayTime, RoomN] . //Examples of DayTime: M2:00AM, W4:50PM, and T8:00PM. Note that DayTime is represented as a string. Student = [studentName, CourseN, Quarter] .................... The DDL statement must include at least the following constraints: Every Primary Key; Every Foreign Key; For every Foreign Key constraint, the referential integrity...

  • For this set of Review Questions, we will create and use a database for the Wedgewood...

    For this set of Review Questions, we will create and use a database for the Wedgewood Pacific Corporation (WPC) that is similar to the Microsoft Access database we created and used in Chapters 1 and 2. Founded in 1957 in Seattle, Washington, WPC has grown into an internationally recognized organization. The company is located in two buildings. One building houses the Administration, Accounting, Finance, and Human Resources departments, and the second houses the Production, Marketing, and Information Systems departments. The...

  • The lab for this week addresses taking a logical database design (data model) and transforming it...

    The lab for this week addresses taking a logical database design (data model) and transforming it into a physical model (tables, constraints, and relationships). As part of the lab, you will need to download the zip file titled CIS336Lab3Files from Doc Sharing. This zip file contains the ERD, Data Dictionary, and test data for the tables you create as you complete this exercise. Your job will be to use the ERD Diagram found below as a guide to define the...

  • Connect to mySQL DBMS, open a SQL script file, navigate to CityJail.sql file and execute it...

    Connect to mySQL DBMS, open a SQL script file, navigate to CityJail.sql file and execute it to create tables and populate with the supplied data. If there are any errors in the script fix them. It is your job to find the errors and correct them. This is important. You will need correct data for future exercises in this module. Then answer all questions. Write the answer below each question then take screen shot of the result. This script builds...

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