Question

1. Write SQL CREATE Table statement to create the following table with Owner ID as a surrogate key. Owner ID is a surrogate k

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

ANSWER

1. SQL Statement

create table pet_owner(ownerID int not null auto_increment,
ownerlastname varchar(10),ownerfirstname varchar(10),
ownerphone varchar(15), owneremail varchar(20),
primary key(ownerID));

Output Screen

MySQL [(none)]> use pet; Database changed MySQL [pet]> create table pet_owner(ownerID int not null auto_increment, ownerlastn

Records are inserted as follows.

insert into pet_owner(ownerlastname,ownerfirstname,ownerphone,owneremail)
values("Jack","Smith","98764521","[email protected]");
insert into pet_owner(ownerlastname,ownerfirstname,ownerphone,owneremail)
values("Johk","Adams","98799521","[email protected]");
insert into pet_owner(ownerlastname,ownerfirstname,ownerphone,owneremail)
values("Joe","Mark","98964521","[email protected]");

MySQL [pet]> insert into pet_owner(ownerlastname, ownerfirstname, ownerphone, owneremail) -> values(Jack, Smith, 9876452

2. SQL statement given below.

create table pet(petId int not null auto_increment,
petname varchar(20), pettype varchar(20), petbreed varchar(20),
petdob date, ownerid int, primary key(petid));

Output screen

MySQL [pet]> create table pet(petId int not null auto_increment, -> petname varchar(20), pettype varchar(20), petbreed varcha

3. SQL statement is given below.

Alter table pet add foreign key(ownerid) references pet_owner(ownerid);

Output screen

MySQL [pet]> Alter table pet add foreign key (ownerid) references pet_owner(ownerid); Query OK, o rows affected (0.158 sec) R

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

    Sample data for these tables are shown in Figures 3-26 and 3-27. For each SQL statement you write, show the results based on these data. If possible, run the statements you write for the questions that follow in an actual DBMS, as appropriate, to obtain results. Use data types that are consistent with the DBMS you are using. If you are not using an actual DBMS, consistently represent data types by using either the MySQL, Microsoft SQL Server, or Oracle...

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

  • The following is the relation notation of the Veterinary Office List. VETERINARY_OFFICE (PetID, PetName, PetType, PetBreed,...

    The following is the relation notation of the Veterinary Office List. VETERINARY_OFFICE (PetID, PetName, PetType, PetBreed, OwnerID, OwnerLastName, OwnerFirstName, ServiceDescription, ServiceDate, ServiceCharge) The functional dependencies are given below: PetID -> PetName, PetType, PetBreed, OwnerID, OwnerLastName, OwnerFirstName OwnerID -> OwnerLastName, OwnerFirstName ServiceDescription -> ServiceCharge PetID, ServiceDate -> ServicedDescription, ServiceCharge Assumption: A pet belongs to only one owner, while an owner may have more than one pet. A pet receives at most one treatment on any given date. Use the functional dependencies...

  • 2. The following is the relation notation of a table for a veterinary office. [70 pts....

    2. The following is the relation notation of a table for a veterinary office. [70 pts. total] VETERINARY_OFFICE (PetID, PetName, PetType, PetBreed, OwnerID, OwnerLastName, OwnerFirstName, ServiceDescription, ServiceDate, ServiceCharge) The functional dependencies are given below: PetID -> PetName, PetType, PetBreed, OwnerID, OwnerLastName, OwnerFirstName OwnerID -> OwnerLastName, OwnerFirstName ServiceDescription -> ServiceCharge PetID, ServiceDate > ServiceDescription, ServiceCharge Assumptions: 1)A pet belongs to only one owner, 2) an owner may have more than one pet, 3A pet receives at most one treatment on any...

  • Create a T-SQL statement that creates a table called Owner as part of a schema called...

    Create a T-SQL statement that creates a table called Owner as part of a schema called PetStore. Create the table to have 2 columns with the following criteria: Column OwnerID of type int. Make this column an IDENTITY column starting with seed 1 and incrementing by 1 Column OwnerName of type varchar and length 50, not null

  • Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmailAddress, OwnerType)...

    Assume that Garden Glory designs a database with the following tables: OWNER (OwnerID, OwnerName, OwnerEmailAddress, OwnerType) OWNED_PROPERTY (PropertyID, PropertyName, PropertyType, Street, City, State, Zip, OwnerID) GG_SERVICE (ServiceID, ServiceDescription, CostPerHour); EMPLOYEE (EmployeeID, LastName, FirstName, CellPhone, ExperienceLevel) PROPERTY_SERVICE (PropertyServiceID, PropertyID, ServiceID, ServiceDate, EmployeeID, HoursWorked) The referential integrity constraints are: OwnerID in OWNED_PROPERTY must exist in OwnerID in OWNER PropertyID in PROPERTY_SERVICE must exist in PropertyID in OWNED_ PROPERTY ServiceID in PROPERTY_SERVICE must exist in ServiceID in GG_SERVICE EmployeeID in PROPERTY_SERVICE must exist...

  • Write an SQL CREATE statement to create the structure of a table to store the following...

    Write an SQL CREATE statement to create the structure of a table to store the following employee information empLastName, empFirstName, Dept (foreign key to department table), emp Address, empZip, empCity, empState. Use appropriate data types to reflect the data which will be stored in each attribute. Identify attributes which should not be null by using the correct SQL statements in the create statement

  • 1) Write a SQL code in order to create a table name Employee with Emp_ID (3...

    1) Write a SQL code in order to create a table name Employee with Emp_ID (3 characters), Last_Name (20 characters), and First_Name (15 characters), the primary key is Emp_ID (Note: make sure this code will run on SQL view on Access database) 2) Write a SQL code to remove the table Employee that will remove both the structure and the content of the table. (

  • Use the SQL statements provided to create your tables. Write one SQL statement for each of...

    Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...

  • Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different tow...

    Q.1] Write SQL statements based on the tennis database schema (practice homework 5) Get all the different town names from the PLAYERS table. 2. For each town, find the number of players. 3. For each team, get the team number, the number of matches that has been played 'for that team, and the total number of sets won. 4. For each team that is captained by a player resident in "Eltham", get the team number and the number of matches...

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