MySQL Problem 1: The STUDENT relation is to be modified by adding an additional
ID: 3754046 • Letter: M
Question
MySQL
Problem 1:
The STUDENT relation is to be modified by adding an additional column SEMESTER. Investigate how it can be done in SQL, and discuss what you have discovered on this. You may try to make an update on this new column, for example, by adding semester values for 3 or 4 entries of the table and see how it turns out. Does the system change the table when modifying the schema, or when updating the table?
Here is the Table Schema:
CNAME 21 Computer Science 17 Chemist 15 PhysicS 12 Mathematics l 13 Mathematics III RESULT CNO CNO STUDENT SNO SNAME ADDRESS SEX SCORE 31 L. Gatlin Holcomb F 11 N. Park Whitney M 22 S. Conner: Holcomb F 24 D. Davissc E. Quad M 19 1. Blake Holcomb M 4 T. Smith Cambridg F SNO 2 2 2 2 2 2 31 14 2 63 4 Histo 3 Geography 2 Biology 72 1 N. J. Sloan Whitney F 14 D. E. Knutl Whitney M 6 J. Brown Whitney 2 M. Robert Cambridg M 14 33 U. Smith Cambridg F 14 37 2 13 13 13 13 97 72 11 NULL 14 61 52 63Explanation / Answer
The System changes the table when modifying the schema itself, when we had successfully created the new column SEMESTER with ALTER clause in the Student table(let's say) the SEMESTER Column will gets added with default value if we had specified, otherwise it comes with null values.
The command to add a column will be as below:
alter table table_name(student) add column column_name(SEMESTER) column_definition(String or Int,etc..) FIRST|AFTER column (Position to add column)
To add the column with default value
alter table table_name add column column_name column_definition(INT) DEFAULT 1;
To update the data: (As you asked to update the data.)
update table_name(student) set SEMESTER="1"(Assumes it to be string type) where student_name="John"
So, finally the System updates the table when you modifying the schema itself but when update the values it will changes with the new data.
In my opinion the solution for your case is the Table updates in case of schema modification itself.
So, if you have any confusion and any doubts in any case kindly please try to comment i will try to respond as soon as possible.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.