In: Computer Science
Consider the following data.
STUDENT |
||||
StudentID |
SName |
Gender |
Age |
ClubID |
3234 |
Alfred Smith |
Male |
20 |
BSK |
2244 |
McJohnson Robert |
Male |
22 |
|
2389 |
Jessica Low |
Female |
20 |
JPA |
4211 |
Roland Devingo |
Male |
24 |
|
4383 |
Jane Usa Khan |
Female |
21 |
BKY |
4450 |
Elaine Fong |
Female |
20 |
JPA |
CLUB |
|||
ClubID |
CName |
Founded |
Budget |
BKY |
Bakery Club |
2010 |
2546 |
PDC |
Photomedia and Design |
2005 |
1345 |
JPA |
Japanese Anime |
2009 |
3453 |
BSK |
Basketball |
2011 |
6744 |
If the database administrator in the University has turned off auto-commit, consider the following:
Student 4211 has joined the Photomedia and Design club. When the system admin wanted to update the database, she wrote the following statement:
UPDATE STUDENT
SET CLUBID = “PDC”
Answer the following:
Given statement:
UPDATE STUDENT
SET CLUBID = “PDC”
a.How does the above SQL statement produce false information in the Student table?
Answer:
STUDENT TABLE:
StudentID | ClubID |
3234 | PDC |
2244 | PDC |
2389 |
PDC |
4211 | PDC |
4383 | PDC |
4450 | PDC |
Correct statement:
UPDATE STUDENT
SET CLUBID = “PDC”
WHERE StudentID = "4211";
STUDENT TABLE:
StudentID | ClubID |
3234 | BSK |
2244 | |
2389 |
JPA |
4211 | PDC |
4383 | BKY |
4450 | JPA |
Note: