In: Computer Science
What is an SQL? Is SQL a standard? Explain.
1B- What are the two categories of SQL statements. Give examples
for each category.
2- Consider the logical schema below:
PET_OWNER(OWNER_ID [N, 18], FIRST_NAME [A, 250], LAST_NAME [A,
250], PHONE [A, 50], EMAIL [A, 250])
PET(PET_ID [N, 18], PET_NAME [N, 18], PET_TYPE [A, 20], BREED [A,
50], DOB [D, 10], OWNER_ID [N, 18])
A- Write an SQL statement to create a database named
PET_OWNER_DB
B- Write SQL statements to create PET_OWNER and PET tables. You
must create the relationship using SQL as well.
C- Write SQL statements to insert one row of data into PET_OWNER
table and one row of data into PET table. Use the below data:
For PET_OWNER use: OWNER_ID=1, FIRST_NAME=Marsha, LAST_NAME=Downs,
Phone: 240-855-2345, [email protected]
For PET use: PET_ID=1, PET_NAME=King, PET_TYPE=Dog, BREED=Cashmere,
DOB=27-Feb-14, OWNER_ID=1
D- Which table's data must be inserted first?
Please donot close the question. paraphrase anything needed please.
Dear Student ,
As per the requirement submitted above , kindly find the below solution.
SQL :
Question 1B :
*******************************
This demonstration is using SQL Server 2014.
Database :
/*create database PET_OWNER_DB*/
create database PET_OWNER_DB;
/*use PET_OWNER_DB to create tables*/
use PET_OWNER_DB;
Tables:
1.Table Name :PET_OWNER
/*1.Table Name :PET_OWNER */
create table PET_OWNER(
OWNER_ID int primary key,
FIRST_NAME varchar(250),
LAST_NAME varchar(250),
PHONE varchar(20),
EMAIL varchar(50));
/*Inserting records*/
insert into PET_OWNER values
(1,'Marsha','Downs','240-855-2345','[email protected]');
/*selecting records*/
select * from PET_OWNER;
Screen in SSMS :
******************************************
2.Table Name :PET
/*2.Table Name :PET*/
create table PET(
PET_ID int primary key,
PET_NAME varchar(50),
PET_TYPE varchar(20),
BREED varchar(50),
DOB date,
OWNER_ID int foreign key references PET_OWNER(OWNER_ID));
/*Inserting records*/
insert into PET values
(1,'King','Dog','Cashmere','27-Feb-14',1);
/*selecting records*/
select * from PET;
Screen in SSMS :
NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.