Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write and Submit the SQL Code to insert a MINIMUM of 5 records into relationship table between charity and volunteer. HINT: You will need to

image text in transcribed

Write and Submit the SQL Code to insert a MINIMUM of 5 records into relationship table between charity and volunteer. HINT: You will need to insert the appropriate records to show that multiple volunteers can donate to the same charity and that one volunteer can donate to multiple charities.

My previous work is below for the questions i worked on earlier.

/* A. Several volunteer opportunities have become available during Spring Break 2018. Create a table named spring_break_2018 with

four columns: an auto incrementing id, the name of the opportunity (e.g. Hurricane Harvey relief), the location of the opportunity (e.g. Houston),

and the cost of the opportunity (e.g. $200). Assume that all costs are in whole dollars (i.e. no fractions of a dollar).

Establish the appropriate relationship between spring_break_2018 and volunteer that multiple volunteers can participate in the same volunteer opportunity.

Write and submit the SQL code to create spring_break_2018 and/or alter volunteer. */

create table spring_break_2018(id int NOT NULL auto_increment, opp_name varchar(40),opp_loc varchar(20), opp_cost int, primary key(id));

alter table volunteer add spid int;

alter table volunteer add foreign key(spid) references spring_break_2018(id);

/* B. Write and submit the SQL code to insert a MINIMUM of 5 records into spring_break_2018. HINT: You will need to have one instance where

two volunteers are participating in the same Spring Break 2018 opportunity to prove that your relationship works. */

insert into spring_break_2018(opp_name, opp_loc, opp_cost)values("Hurricane","Florida", 300);

insert into spring_break_2018(opp_name, opp_loc, opp_cost) values ("Flood", "Georgia", 400);

insert into spring_break_2018(opp_name, opp_loc, opp_cost) values ("Earthquake" , "Alaska", 200);

insert into spring_break_2018(opp_name, opp_loc, opp_cost) values ("Landslide" , "Oregon" ,100);

insert into spring_break_2018(opp_name, opp_loc, opp_cost) values ("Tornado" , "Texas" , 500);

/* C. Write a query to demonstrate that returns the volunteers name and the Spring Break 2018 opportunity. */

select first_name, last_name, opp_name from volunteer, spring_break_2018 where volunteer.major_id = spring_break_2018.id;

/* D. Create a table named charity with two columns: an auto incrementing id and the name of the charity that volunteers can donate to.

Some charities can include, but are certainly not limited to, American Red Cross, American Cancer Society, Puppies Behind Bars, St Judes Childrens Hospital, etc.

Establish the appropriate relationship between charity and volunteer so that one volunteer can donate to multiple charities and that one charity can have multiple

volunteers donating to it. For each donation, also record the amount donated (assume that the donation is a whole number).

Write and submit the SQL code to create charity and any other necessary table. */

Create table charity (

id int auto_increment,

charity_name varchar(30),

primary key (id)

);

insert into charity (charity_name)

values ('American Red Cross'),('American Cancer Society'), ('Puppies Behind Bars'),('St. Judes Childrens Hospital');

Create Table donation (

volunteer_id varchar(6),

charity_id int,

donation_amount int,

primary key (volunteer_id,charity_id),

constraint volunteer_id foreign key (volunteer_id) references volunteer(xnumber),

constraint charity_id foreign key (charity_id) references charity(id)

);

volunter_hours vaunter_date DATE arganizatian VARCHAR(45) company d VARCHAR2) arracks VARCHAR 15) ac VARCHAR 45 donatin chanty id INT(11) danstion amaunt INT11 volunterknowsforeign language vounteer_xnumber VARCHAR6 volunteer profcency VARCHAR(45) bVARCHAR(E sexVARCHAR 5 date o bith DATE grad year YEA(4) major id INT11) charity d INT(11) VARCHAR30) pany-id VARCHAR(2) Indexes pd INT11) i INT 11) VARCHAR(45) department VARCHAR 45) spring-break-2018 d INT(11) appname VARCHAR(40) app.bcVAR AR20) foreign language dINT(11)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago