Question

In: Computer Science

You should try this code in Microsoft SQL Server to get the practice of using the...

You should try this code in Microsoft SQL Server to get the practice of using the command line and getting syntax errors. You can submit to me your sql files or just copy and paste of your code in a word document. I may try to run it, so make sure it is error free. Or you can show screen shots of code running.

  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!

  1. Write SQL CREATE Table statement to create the following table with  Pet ID as a surrogate key.  Pet ID is a surrogate key (starts at 1 and increments by 1)

hint: IDENTITY (1, 1) syntax for surrrogate key..

PET (PetID, PetName, PetType, PetBreed, PetDOB, OwnerID)

You don’t need to create referential integrity constraint on OwnerID in PET table.

  1. Now create the referential integrity constraint on OwnerID in PET. You can use ALTER TABLE command.

Solutions

Expert Solution

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.

CREATE TABLE PET_OWNER(

OwnerID Int IDENTITY(1, 1) NOT NULL,

OwnerLastName Char(25) NOT NULL,

OwnerFirstName Char(25) NOT NULL,

OwnerPhone Char(12) NULL,

OwnerEmail VarChar(100) NULL,

CONSTRAINT OWNER_PK PRIMARY KEY(OwnerID)

);

Inserting some data into your tables :

INSERT INTO PET_OWNER (OwnerLastName, OwnerFirstName, OwnerPhone,OwnerEmail) VALUES('Downs', 'Marsha', '555-537-8765', '[email protected]');

INSERT INTO PET_OWNER (OwnerLastName, OwnerFirstName,OwnerPhone, OwnerEmail) VALUES('James', 'Richard', '555-537-7654', '[email protected]');

INSERT INTO PET_OWNER (OwnerLastName, OwnerFirstName, OwnerPhone,OwnerEmail) VALUES('Frier', 'Liz', '555-537-6543', '[email protected]');

INSERT INTO PET_OWNER (OwnerLastName, OwnerFirstName,OwnerPhone, OwnerEmail) VALUES('Trent', 'Miles', ' ','[email protected]');

SELECT * FROM PET_OWNER;

2. Write SQL CREATE Table statement to create the following table with  Pet ID as a surrogate key.  Pet ID is a surrogate key (starts at 1 and increments by 1)

hint: IDENTITY (1, 1) syntax for surrrogate key..

CREATE TABLE PET(

PetID Int IDENTITY(1,1) NOT NULL,

PetName Char (50) NOT NULL,

PetType Char (25) NOT NULL,

PetBreed VarChar(100) NULL,

PetDOB Date NULL,

OwnerID Int NOT NULL,

CONSTRAINT PET_PK PRIMARY KEY(PetID)

);

  1. create the referential integrity constraint on OwnerID in PET. You can use ALTER TABLE command.

ALTER TABLE PET

ADD CONSTRAINT OWNER_FK FOREIGN KEY(OwnerID) REFERENCES PET_OWNER(OwnerID);

Inserting some data into your tables :

INSERT INTO PET VALUES( 'King', 'Dog', 'Std.Poodle','2011-02-27',1);

INSERT INTO PET VALUES( 'Teddy', 'Dog', 'Std.Poodle','2012-02-01',2);

INSERT INTO PET VALUES( 'Fido', 'Dog', 'Std.Poodle','2010-07-17',1);

INSERT INTO PET VALUES( 'Aj', 'Dog', 'Collie Mix','2011-05-05',3);

INSERT INTO PET VALUES( 'Cedro', 'Cat', 'Unknown','2009-06-06',2);

INSERT INTO PET VALUES( 'Wolley', 'Cat', 'Unknown',' ',2);

INSERT INTO PET VALUES( 'Buster', 'Dog', 'BorderCollie','2008-12-11',4);

SELECT * FROM PET;


Related Solutions

You should try this code in Microsoft SQL Server to get the practice of using the...
You should try this code in Microsoft SQL Server to get the practice of using the command line and getting syntax errors. You can submit to me your sql files or just copy and paste of your code in a word document. I may try to run it, so make sure it is error free. Or you can show screen shots of code running. Write SQL CREATE Table statement to create the following table with  Owner ID  as a surrogate key.  Owner ID...
Research Microsoft SQL Server and in your own words, describe your understanding of this and its...
Research Microsoft SQL Server and in your own words, describe your understanding of this and its role in Microsoft's model for web programming. Be sure to list your sources by providing links and/or printed book/article names. As one open option available to us is Microsoft SQL Server Express, for your response discuss too which is better for development. SQL Server Express or a full SQL Server environment?
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least...
Using your downloaded DBMS (MS SQL Server or MySQL), write SQL queries that inserts at least three rows in each table. For the On-Demand Streaming System, First, insert information for multiple users, at least three video items and insert the three different types of subscriptions (Basic, Advanced, Unlimited) into the database. Then insert at least three user subscriptions. Execute the queries and make sure they run correctly
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
I am working on an assignment using SQL Server Management and I need to print an...
I am working on an assignment using SQL Server Management and I need to print an ERD to a single page as a PDF file. I am not sure how to do this especially because the diagram is rather large... I am using SQL Server Management Studio I have created an Entity relationship diagram for AdventureWorks that includes all product tables. There are many tables.How do I print it to a single page?
should the federal reserve try to get the inflation rate to zero?
should the federal reserve try to get the inflation rate to zero?
In the Topic Materials, you learned about exporting SQL Server Data to Excel. Explain the two...
In the Topic Materials, you learned about exporting SQL Server Data to Excel. Explain the two options for exporting data using the SQL Server Import and Export Wizard, and provide examples of when each option should be selected.
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
Pretend you are writing a SQL Code for a database with aHomeowners Insurance Company.Use...
Pretend you are writing a SQL Code for a database with a Homeowners Insurance Company.Use Microsoft SQL to write a code for the following:Create a new table called Policy_Total. It will contain the number of policies in the policy table. Create a trigger that increments the policy total every time a policy is added. Create another trigger that decrements the policy total every time a policy is deleted.Create a stored procedure that compares the policy total field from the Policy...
(Complete Using Ubuntu) Please try each command in Linux system, and get screenshots (you may put...
(Complete Using Ubuntu) Please try each command in Linux system, and get screenshots (you may put multiple commands in one screenshot) which can show how actually each command runs. Also, give a brief description (one or two sentences) for each command. For the commands which have multiple switches/parameters, please try one popular switch/parameter. Linux Commands: rm,cp ,mv (name), ld, ftp, more, less, cat (date), tar, top, ps (name), kill, df, last, patch, mkdir (date)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT