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...
Which of the following is a database client software? Microsoft SQL Server 2017 Developer Microsoft SQL...
Which of the following is a database client software? Microsoft SQL Server 2017 Developer Microsoft SQL Server Management Studio Microsoft SQL Server Configuration Manager SQL Server Analysis Service Compared to Data Warehousing approach, the following are disadvantages of query-driven data integration approach, EXCEPT: __________. competition with local processing at source delay in query processing waste of storage space inefficient and potentially expensive for frequent queries What does OLAP stand for? Olympic Linear Algebra Problem On-Line Amazon Platform On-Line Analytical Processing...
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?
6-Microsoft SQL Server is a​ ________ for large mainframes and midrange computers. A.SimpleDB B.MongoDB C.relational DBMS...
6-Microsoft SQL Server is a​ ________ for large mainframes and midrange computers. A.SimpleDB B.MongoDB C.relational DBMS D.NoSQL E.distributed database 16-SQL stands for​ ________. A.Structured Query Language B.Streamlined Question Language C.Structured Question Language D.Special Question Language E.Structured Questioning Language 18-Which of the following is a distributed database technology that enables firms and organizations to create and verify transactions on a​ peer-to-peer network nearly instantaneously without a central​ authority? A.MySQL B.DB2 C.NoSQL D.Blockchain E.Cloud Spinner 19-What makes a Blockchain system possible and...
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?
(Try to work this question WITHOUT using Excel, get answer by using the formula and show...
(Try to work this question WITHOUT using Excel, get answer by using the formula and show the calculations in detail) Question (Retirement planning) You have just graduated Hofstra University at age 22. You hard work has paid off as you already have a job as an investment banker at Goldman Sachs waiting for you. You plan to work continuously until age 65 and retire exactly on that day. You expect to live until exactly 90 and enjoy your golden years...
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT