Question

In: Computer Science

The score recorded for student 12 for event 5 is incorrect. The score should be a...

  1. The score recorded for student 12 for event 5 is incorrect. The score should be a 10. Make this change to the database table.

      a. What construct did you use? Insert the snip of your SQL code here:

      b. Display the contents of the score table for event 5. Be sure student 12 is displayed. Insert your snip here:

*************************************************************

DATABASE

************************************************************


#---Create and open the database

drop database if exists Class;

CREATE DATABASE Class;


#-- Using the database

USE Class;

# create student table


DROP TABLE IF EXISTS student;

CREATE TABLE student

(
  
name VARCHAR(20) NOT NULL,
  
gender ENUM('F','M') NOT NULL,
  
student_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  
PRIMARY KEY (student_id)

);

# create grade event table

DROP TABLE IF EXISTS grade_event;

CREATE TABLE grade_event

(
  
date DATE NOT NULL,
  
category ENUM('T','Q') NOT NULL,
  
event_id INT UNSIGNED NOT NULL AUTO_INCREMENT,
  
PRIMARY KEY (event_id)

);

# create score table


# The PRIMARY KEY comprises two columns to prevent any combination
# of event_id/student_id from appearing more than once.


DROP TABLE IF EXISTS score;


CREATE TABLE score

(
  
student_id INT UNSIGNED NOT NULL,
  
event_id INT UNSIGNED NOT NULL,
  
score INT NOT NULL,
  
PRIMARY KEY (event_id, student_id),
  
INDEX (student_id),
  
FOREIGN KEY (event_id) REFERENCES grade_event (event_id),
  
FOREIGN KEY (student_id) REFERENCES student (student_id)

);

# create absence table


DROP TABLE IF EXISTS absence;

CREATE TABLE absence

(
  
student_id INT UNSIGNED NOT NULL,
  
date DATE NOT NULL,
  
PRIMARY KEY (student_id, date),
  
FOREIGN KEY (student_id) REFERENCES student (student_id)

);

#--Populate the student table


INSERT INTO student VALUES ('Megan','F',NULL);

INSERT INTO student VALUES ('Joseph','M',NULL);

INSERT INTO student VALUES ('Kyle','M',NULL);

INSERT INTO student VALUES ('Katie','F',NULL);

INSERT INTO student VALUES ('Abby','F',NULL);

INSERT INTO student VALUES ('Nathan','M',NULL);

INSERT INTO student VALUES ('Liesl','F',NULL);

INSERT INTO student VALUES ('Ian','M',NULL);

INSERT INTO student VALUES ('Colin','M',NULL);

INSERT INTO student VALUES ('Peter','M',NULL);

INSERT INTO student VALUES ('Michael','M',NULL);

INSERT INTO student VALUES ('Thomas','M',NULL);

INSERT INTO student VALUES ('Devri','F',NULL);

INSERT INTO student VALUES ('Ben','M',NULL);

INSERT INTO student VALUES ('Aubrey','F',NULL);

INSERT INTO student VALUES ('Rebecca','F',NULL);

INSERT INTO student VALUES ('Will','M',NULL);

INSERT INTO student VALUES ('Max','M',NULL);

INSERT INTO student VALUES ('Rianne','F',NULL);

INSERT INTO student VALUES ('Avery','F',NULL);

INSERT INTO student VALUES ('Lauren','F',NULL);

INSERT INTO student VALUES ('Becca','F',NULL);

INSERT INTO student VALUES ('Gregory','M',NULL);

INSERT INTO student VALUES ('Sarah','F',NULL);

INSERT INTO student VALUES ('Robbie','M',NULL);

INSERT INTO student VALUES ('Keaton','M',NULL);

INSERT INTO student VALUES ('Carter','M',NULL);

INSERT INTO student VALUES ('Teddy','M',NULL);

INSERT INTO student VALUES ('Gabrielle','F',NULL);

INSERT INTO student VALUES ('Grace','F',NULL);

INSERT INTO student VALUES ('Emily','F',NULL);

INSERT INTO student VALUES ('Rachel','F',NULL);


#--Populate grade event table

INSERT INTO grade_event VALUES('2015-09-03', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-09-06', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-09-09', 'T', NULL);
INSERT INTO grade_event VALUES('
2015-09-16', 'Q', NULL);
INSERT INTO grade_event VALUES(
'2015-09-23', 'Q', NULL);
INSERT INTO grade_event VALUES('
2015-10-01', 'T', NULL);


#--Populate the score table


INSERT INTO score VALUES (1,1,20);

INSERT INTO score VALUES (3,1,20);

INSERT INTO score VALUES (4,1,18);

INSERT INTO score VALUES (5,1,13);

INSERT INTO score VALUES (6,1,18);

INSERT INTO score VALUES (7,1,14);

INSERT INTO score VALUES (8,1,14);

INSERT INTO score VALUES (9,1,11);

INSERT INTO score VALUES (10,1,19);

INSERT INTO score VALUES (11,1,18);

INSERT INTO score VALUES (12,1,19);

INSERT INTO score VALUES (14,1,11);

INSERT INTO score VALUES (15,1,20);

INSERT INTO score VALUES (16,1,18);

INSERT INTO score VALUES (17,1,9);

INSERT INTO score VALUES (18,1,20);

INSERT INTO score VALUES (19,1,9);

INSERT INTO score VALUES (20,1,9);

INSERT INTO score VALUES (21,1,13);

INSERT INTO score VALUES (22,1,13);

INSERT INTO score VALUES (23,1,16);

INSERT INTO score VALUES (24,1,11);

INSERT INTO score VALUES (25,1,19);

INSERT INTO score VALUES (26,1,10);

INSERT INTO score VALUES (27,1,15);

INSERT INTO score VALUES (28,1,15);

INSERT INTO score VALUES (29,1,19);

INSERT INTO score VALUES (30,1,17);

INSERT INTO score VALUES (31,1,11);

INSERT INTO score VALUES (1,2,17);

INSERT INTO score VALUES (2,2,8);

INSERT INTO score VALUES (3,2,13);

INSERT INTO score VALUES (4,2,13);

INSERT INTO score VALUES (5,2,17);

INSERT INTO score VALUES (6,2,13);

INSERT INTO score VALUES (7,2,17);

INSERT INTO score VALUES (8,2,8);

INSERT INTO score VALUES (9,2,19);

INSERT INTO score VALUES (10,2,18);

INSERT INTO score VALUES (11,2,15);

INSERT INTO score VALUES (12,2,19);

INSERT INTO score VALUES (13,2,18);

INSERT INTO score VALUES (14,2,18);

INSERT INTO score VALUES (15,2,16);

INSERT INTO score VALUES (16,2,9);

INSERT INTO score VALUES (17,2,13);

INSERT INTO score VALUES (18,2,9);

INSERT INTO score VALUES (19,2,11);

INSERT INTO score VALUES (21,2,12);

INSERT INTO score VALUES (22,2,10);

INSERT INTO score VALUES (23,2,17);
INSERT INTO score VALUES (24,2,19);

INSERT INTO score VALUES (25,2,10);

INSERT INTO score VALUES (26,2,18);

INSERT INTO score VALUES (27,2,8);

INSERT INTO score VALUES (28,2,13);

INSERT INTO score VALUES (29,2,16);

INSERT INTO score VALUES (30,2,12);

INSERT INTO score VALUES (31,2,19);

INSERT INTO score VALUES (1,3,88);

INSERT INTO score VALUES (2,3,84);

INSERT INTO score VALUES (3,3,69);

INSERT INTO score VALUES (4,3,71);

INSERT INTO score VALUES (5,3,97);

INSERT INTO score VALUES (6,3,83);

INSERT INTO score VALUES (7,3,88);
INSERT INTO score VALUES (8,3,75);

INSERT INTO score VALUES (9,3,83);

INSERT INTO score VALUES (10,3,72);
INSERT INTO score VALUES (11,3,74);

INSERT INTO score VALUES (12,3,77);

INSERT INTO score VALUES (13,3,67);
INSERT INTO score VALUES (14,3,68);

INSERT INTO score VALUES (15,3,75);

INSERT INTO score VALUES (16,3,60);

INSERT INTO score VALUES (17,3,79);

INSERT INTO score VALUES (18,3,96);

INSERT INTO score VALUES (19,3,79);

INSERT INTO score VALUES (20,3,76);

INSERT INTO score VALUES (21,3,91);

INSERT INTO score VALUES (22,3,81);

INSERT INTO score VALUES (23,3,81);

INSERT INTO score VALUES (24,3,62);

INSERT INTO score VALUES (25,3,79);

INSERT INTO score VALUES (26,3,86);

INSERT INTO score VALUES (27,3,90);

INSERT INTO score VALUES (28,3,68);

INSERT INTO score VALUES (29,3,66);

INSERT INTO score VALUES (30,3,79);

INSERT INTO score VALUES (31,3,81);

INSERT INTO score VALUES (2,4,7);

INSERT INTO score VALUES (3,4,17);

INSERT INTO score VALUES (4,4,16);

INSERT INTO score VALUES (5,4,20);

INSERT INTO score VALUES (6,4,9);

INSERT INTO score VALUES (7,4,19);

INSERT INTO score VALUES (8,4,12);

INSERT INTO score VALUES (9,4,17);

INSERT INTO score VALUES (10,4,12);

INSERT INTO score VALUES (11,4,16);

INSERT INTO score VALUES (12,4,13);

INSERT INTO score VALUES (13,4,8);

INSERT INTO score VALUES (14,4,11);

INSERT INTO score VALUES (15,4,10);

INSERT INTO score VALUES (16,4,20);

INSERT INTO score VALUES (18,4,11);

INSERT INTO score VALUES (19,4,15);

INSERT INTO score VALUES (20,4,17);

INSERT INTO score VALUES (21,4,13);

INSERT INTO score VALUES (22,4,20);

INSERT INTO score VALUES (23,4,13);

INSERT INTO score VALUES (24,4,12);
INSERT INTO score VALUES (25,4,10);

INSERT INTO score VALUES (26,4,15);

INSERT INTO score VALUES (28,4,17);

INSERT INTO score VALUES (30,4,11);

INSERT INTO score VALUES (31,4,19);

INSERT INTO score VALUES (1,5,15);

INSERT INTO score VALUES (2,5,12);

INSERT INTO score VALUES (3,5,11);

INSERT INTO score VALUES (5,5,13);

INSERT INTO score VALUES (6,5,18);

INSERT INTO score VALUES (7,5,14);

INSERT INTO score VALUES (8,5,18);

INSERT INTO score VALUES (9,5,13);

INSERT INTO score VALUES (10,5,14);

INSERT INTO score VALUES (11,5,18);

INSERT INTO score VALUES (12,5,8);

INSERT INTO score VALUES (13,5,8);

INSERT INTO score VALUES (14,5,16);

INSERT INTO score VALUES (15,5,13);

INSERT INTO score VALUES (16,5,15);

INSERT INTO score VALUES (17,5,11);

INSERT INTO score VALUES (18,5,18);

INSERT INTO score VALUES (19,5,18);
INSERT INTO score VALUES (20,5,14);

INSERT INTO score VALUES (21,5,17);

INSERT INTO score VALUES (22,5,17);

INSERT INTO score VALUES (23,5,15);

INSERT INTO score VALUES (25,5,14);

INSERT INTO score VALUES (26,5,8);

INSERT INTO score VALUES (28,5,20);

INSERT INTO score VALUES (29,5,16);

INSERT INTO score VALUES (31,5,9);

INSERT INTO score VALUES (1,6,100);

INSERT INTO score VALUES (2,6,91);

INSERT INTO score VALUES (3,6,94);

INSERT INTO score VALUES (4,6,74);

INSERT INTO score VALUES (5,6,97);

INSERT INTO score VALUES (6,6,89);

INSERT INTO score VALUES (7,6,76);

INSERT INTO score VALUES (8,6,65);

INSERT INTO score VALUES (9,6,73);

INSERT INTO score VALUES (10,6,63);

INSERT INTO score VALUES (11,6,98);

INSERT INTO score VALUES (12,6,75);

INSERT INTO score VALUES (14,6,77);

INSERT INTO score VALUES (15,6,62);

INSERT INTO score VALUES (16,6,98);

INSERT INTO score VALUES (17,6,94);

INSERT INTO score VALUES (18,6,94);

INSERT INTO score VALUES (19,6,74);
INSERT INTO score VALUES (20,6,62);

INSERT INTO score VALUES (21,6,73);

INSERT INTO score VALUES (22,6,95);

INSERT INTO score VALUES (24,6,68);

INSERT INTO score VALUES (25,6,85);

INSERT INTO score VALUES (26,6,91);
INSERT INTO score VALUES (27,6,70);

INSERT INTO score VALUES (28,6,77);

INSERT INTO score VALUES (29,6,66);

INSERT INTO score VALUES (30,6,68);

INSERT INTO score VALUES (31,6,76);


#--Populate the absence table

INSERT INTO `absence` VALUES (3,'2015-09-03');

INSERT INTO `absence` VALUES (5,'2015-09-03');

INSERT INTO `absence` VALUES (10,'2015-09-06');

INSERT INTO `absence` VALUES (10,'2015-09-09');

INSERT INTO `absence` VALUES (17,'2015-09-07');

INSERT INTO `absence` VALUES (20,'2015-09-07');

INSERT INTO `absence` VALUES (22,'2015-09-15');

Solutions

Expert Solution

Score table(below) before updating the score of student 12 in event 5

To update the score, we use the UPDATE construct which has the below syntax.

UPDATE table_name

SET column_1= value1,

column_2=value2,

....

WHERE condition;

1. Specify the table name in which a value needs to be changed/updated after the UPDATE construct.

2. Specify the column/columns and their corresponding new values after the SET keyword.

3. Specify the condition after the WHERE clause to apply the update to specific rows. The WHERE clause is optional. If we do not specify, the update will happen for all the rows.

Here is the snip of the construct used to change the value of score from 8 to 10 for student id 12 in event 5.

score table after updating the score value


Related Solutions

Create a view that will display the student id, name, event id, category, and score for...
Create a view that will display the student id, name, event id, category, and score for all events for students who scored a 70 or below on any test. Call this view atriskstudents. a. What code did you write for this view? Insert the snip of the contents of the view SQL code here: b. Using this view, display those students who earned a score of 65 or greater. Insert your snip here *********************************************************************************************************************************************************** *********************************************************************************************************************************************************** CREATE DATABASE Class; #-- Using...
5 students attending an exam. Let Si be the event of student i passes an exam....
5 students attending an exam. Let Si be the event of student i passes an exam. S1 and S2 may or may not be independent of each other. Let random variable X be total number of students who pass the exam. P(S1) = P(S2) = 2/3. X = 0, 1, 2, 3, 4, 5. 1) E(X) 2) What is the min and max of var(X)
Develop a program that calculates the final score and the average score for a student from...
Develop a program that calculates the final score and the average score for a student from his/her (1)class participation, (2) test, (3) assignment, (4) exam, and (5) practice scores. The user should enter the name of the student and scores ranging from 0 to 100 for each grading item. The final score is the sum of all grading items. The average score is the average of all grading items. Here is a sample output of the program: Enter the Student's...
Generals Warriors Student WAIS-IV Score Student WAIS-IV Score 1 105 1 93 2 81 2 90...
Generals Warriors Student WAIS-IV Score Student WAIS-IV Score 1 105 1 93 2 81 2 90 3 102 3 87 4 90 4 109 5 95 5 106 6 110 6 104 7 90 7 109 8 100 8 104 9 80 9 115 10 90 10 112 11 84 11 112 12 81 12 100 13 90 13 97 14 107 14 90 15 101 15 104 16 90 16 107 17 101 A. Complete the group frequency table....
1. A student takes a 12 question multiple choice test. There are 5 answer choices, and...
1. A student takes a 12 question multiple choice test. There are 5 answer choices, and the student guesses on all the questions. What is the probability the student will get exactly 7 questions correct in order to pass? Round to 5 decimal places. a. 0.00332 b. 0.00587 c. 0.08304 d. 0.00213 2. If the probability of a machine producing a defective part is 0.05, what is the probability of finding exactly 5 defective parts from a sample of 100?...
A retired statistics professor has recorded results for decades. The mean score for the population of...
A retired statistics professor has recorded results for decades. The mean score for the population of her students is 82.4 with a standard deviation of 6.5 . In the last year, her mean seems to have changed. She bases this on a random sample of 25 students whose scores had a mean of 80 with a standard deviation of 4.2 . Test the professor's claim that the current mean is different from 82.4 . Use α = .05 . Assume...
Consider randomly selecting a student at a large university, and let "A" be the event that...
Consider randomly selecting a student at a large university, and let "A" be the event that the selected student has a Visa card and "B" be the analogous event for MasterCard. Suppose that P(A)=0.6 and P(B)=0.4. a) Could it be the case that P(A and B)=0.5? Why or why not?
The probability that a student correctly answers on the first try (the event A) is P(A)...
The probability that a student correctly answers on the first try (the event A) is P(A) = 0.3. If the student answers incorrectly on the first try, the student is allowed a second try to correctly answer the question (the event B). The probability that the student answers correctly on the second try given that he answered incorrectly on the first try is 0.4. Find the probability that the student answers the question on the first or second try. a)...
Consider randomly selecting a student at a large university, and let A be the event that...
Consider randomly selecting a student at a large university, and let A be the event that the selected student has a Visa card and B be the analogous event for MasterCard. Suppose thatP(A) = 0.7and P(B) = 0.3. (a)Could it be the case thatP(A ∩ B) = 0.5? Why or why not? (b) From now on, suppose thatP(A ∩ B) = 0.2. What is the probability that the selected student has at least one of these two types of cards?...
Consider randomly selecting a student at a large university. Let A be the event that the...
Consider randomly selecting a student at a large university. Let A be the event that the selected student has a Visa card, let B be the analogous event for MasterCard, and let C be the event that the selected student has an American Express card. Suppose that P(A) = 0.6,P(B) = 0.4,and P(A ∩ B) = 0.3,suppose that P(C) = 0.2,P(A ∩ C) = 0.12,P(B ∩ C) = 0.1, and P(A ∩ B ∩ C) = 0.08. a)What is the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT