Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem 1 here: https://www.chegg.com/homework-help/questions-and-answers/databa

ID: 3888648 • Letter: P

Question

Problem 1 here: https://www.chegg.com/homework-help/questions-and-answers/database-systems-sql-problem-1-matrix-manipulations-optimal-use-sql-matrix-operations-impl-q23843783

Database Systems, SQL

Problem 2: The Pets Database

There is another way to import data into mysql. When you start mysql, you should use the –-enable-local-infile option:

sudo mysql –-enable-local-infile –u root

This allows you to import individual tables into a database. Create a new database called pets.

a)Create two tables:

Pet(name:VARCHAR(20),owner:VARCHAR(20),

species:VARCHAR(20),sex:CHAR(1),birth:DATE,death:DATE)

and

Event(name:VARCHAR(20),date:DATE,type:VARCHAR(15),

remark:VARCHAR(255))

b)Load data into these tables using the two file provided , Pet Table Data and Pet Events Table Data. You can use the following command syntax example for Pet Table Data:

mysql> LOAD DATA LOCAL INFILE “Pet Table Data.txt” INTO TABLE pet FIELDS TERMINATED BY ‘,’;

c)Write a SQL query against this database. We’d like to see all the male cats and all the female dogs.

d)Write a SQL query that provides the age of each pet that has had a litter.

Pet Table Data

Pet Events Table Data

Explanation / Answer

Hi,
To print all male dogs and female cats
select * from Pet where species='dog' and sex='f' union
select * from pet where species='cat' and sex='m' ;
using union to join to condiitons
2.age of each pet that had a litter
select age from Pet a, Event b where b.name='litter' and b.name=a.name;
using joing to get all those pet names who had litter
Thumbs up if this was helpful, otherwise let me know in comments

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote