0% found this document useful (0 votes)
45 views

SQL Query

The document describes creating a student record management database with a table to store student data. It outlines 12 common operations on the student records like creating, retrieving, updating, deleting individual or multiple records based on certain conditions. These operations can be performed using SQL statements like INSERT, SELECT, UPDATE, DELETE, ALTER with appropriate clauses.

Uploaded by

janet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views

SQL Query

The document describes creating a student record management database with a table to store student data. It outlines 12 common operations on the student records like creating, retrieving, updating, deleting individual or multiple records based on certain conditions. These operations can be performed using SQL statements like INSERT, SELECT, UPDATE, DELETE, ALTER with appropriate clauses.

Uploaded by

janet
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Student Record Management

Create a simple Database of a school's student management system. Wewill


createadatabase table named "students" with the following fields:
● student_id (auto-incremented primary key)
● first_name ()
● last_name ()
● email ()
● phone_number ()
● address ()
Note: Give proper data types and constraints for the above columns. Now let's consider
the CRUD operations that can be performed on this "students"table:1. Create a new
student record:

● The system allows school administrators to add a new student recordtothe"students"table.


They can enter the student's first name, last name, email, phone number, andaddress into a
form.
● Upon submitting the form, the system will insert the new student recordintothe"students"
table.
2. Retrieve a student record:
● The system allows school administrators to search for a specific student
recordbytheirstudent_id.
● Upon entering the student_id, the system retrieves the student's details
fromthe"students" table and displays them on the screen.
3. Update a student record:
● The system allows school administrators to update an existing student
recordinthe"students" table.
● They can select a student record by their student_id and update any of
thefields(firstname, last name, email, phone number, or address) in the record.
● Upon submitting the update, the system will modify the corresponding
recordinthe"students" table.
4. Delete a student record:

● The system allows school administrators to delete an existing student


recordfromthe"students" table.
● They can select a student record by their student_id and delete the correspondingrecord.
Upon deletion, the system will remove the record fromthe "students"table.

5. Update multiple student records:


● The system allows school administrators to update multiple student
recordsinthe"students" table that meet a certain condition.
● For example, the system may allow administrators to update the
phonenumberofallstudents who have not provided a phone number yet.
● This can be accomplished by using the SET and WHERE clauses in an UPDATEstatement.The
SET clause will update the phone number field of all records that matchtheWHEREcondition.

6. Delete multiple student records:


● The system allows school administrators to delete multiple student records
fromthe"students" table that meet a certain condition.
● For example, the system may allow administrators to delete all records of
studentswhohave graduated from the school.
● This can be accomplished by using the WHERE clause in a DELETE statement tospecifythe
condition that must be met for a record to be deleted.

7. Retrieve a subset of student records:


● The system allows school administrators to retrieve a subset of student
recordsfromthe"students" table based on a certain condition.
● For example, the system may allow administrators to retrieve all records of studentswho
have a certain grade point average (GPA) or who are enrolled in a particularcourse.
● This can be accomplished by using the WHERE clause in a SELECT statement tospecifythe
condition that must be met for a record to be retrieved.

8. Update a subset of student records:

● The system allows school administrators to update a subset of student


recordsinthe"students" table based on a certain condition.
● For example, the system may allow administrators to update the email
addressesofallstudents who are enrolled in a particular course.
● This can be accomplished by using the SET and WHERE clauses in an UPDATEstatementto
specify the fields that need to be updated and the condition that must bemetforarecord to be
updated

9. Add a new column to the students table:


● The system allows school administrators to add a new column to the "students"tableifthey
need to store additional information about the students.
● For example, they may need to add a "date_of_birth" column to store thestudents'birth
dates. This can be accomplished by using the ALTER TABLE statement withtheADDCOLUMN
keyword.

10. Modify an existing column in the students table:


● The system allows school administrators to modify an existing columninthe"students"table
if they need to change the data type, size, or other properties of thecolumn.
● For example, they may need to increase the size of the "address"
columntoallowforlonger addresses.
● This can be accomplished by using the ALTER TABLE statement with theMODIFYCOLUMN
keyword.

11. Rename a column in the students table:


● The system allows school administrators to rename an existing
columninthe"students"table if they need to make the column name more descriptive or
accurate.
● For example, they may need to rename the "phone_number"
columnto"contact_number" to include both phone and email addresses.

● This can be accomplished by using the ALTER TABLE statement with theCHANGECOLUMN or
RENAME COLUMN keyword.

12. Drop a column from the students table:


● The system allows school administrators to drop an existing column fromthe"students"table
if they no longer need the data stored in that column.
● For example, they may need to drop the "middle_name" column if they decidenottocollect
that information from the students.
● This can be accomplished by using the ALTER TABLE statement with
theDROPCOLUMNkeyword.

Note: You have to do above all the operations using your table.

You might also like