Question
Database Structures SQL Write SQL code to complete the following (create and insert data into the following tables) and run the code in MS SQL
Database Structures SQL
Write SQL code to complete the following (create and insert data into the following tables) and run the code in MS SQL SERVER to get practice using the command line and getting syntax errors. You can submit your sql files or just copy and paste your code in notepad or in a word document. I may try to run your code, so be sure it is error free, or you can send me a screen shot that your code ran. Be sure I can see your id in the SQL window so I know it is your work.
1. Write SQL CREATE table statement to create the following table with OwnerID as surrogate key. OwnerID 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)
2. Write SQL CREATE table statement to create the following table with PetID as surrogate key. PetID is a surrogate key (starts at 1 and increments by 1). hint: IDENTITY (1,1) is syntax for surrogate key
PET (PetID, PetName, PetType, PetBreed, PetDOB, OwnerID), you don't need to create referential integrity constraint on OwnerID in PET table yet.
3. Using the ALTER table command, add referential integrity constraint on OwnerID in the PET table.
Hint: (OwnerID ) REFERENCES PET_OWNER (OwnerID ). You will need to figure out the syntax to alter PET table and it references PET_OWNER.
4. Add some records to PET_OWNER table.
5. Add some records to PET Table, note you will need to have valid Owner_IDs if you set up the referential integrity constraint or SQL will not allow you to enter records that don't have a corresponding OwnerID in the Pet_Owner table.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started