0% found this document useful (0 votes)
7 views2 pages

Unit 5

This document provides an overview of database operations using MySQL and PHP, covering topics such as creating databases, establishing connections, and performing CRUD operations. It includes specific SQL commands and PHP scripts for tasks like inserting, updating, and deleting data, as well as conceptual questions about database design and performance. Key differences between MySQL commands and PHP functions are also discussed.

Uploaded by

SIDDHI DARWADE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Unit 5

This document provides an overview of database operations using MySQL and PHP, covering topics such as creating databases, establishing connections, and performing CRUD operations. It includes specific SQL commands and PHP scripts for tasks like inserting, updating, and deleting data, as well as conceptual questions about database design and performance. Key differences between MySQL commands and PHP functions are also discussed.

Uploaded by

SIDDHI DARWADE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit-V Database Operations

5.1 Introduction to MySQL – Creating a Database

1. What is MySQL? Why is it commonly used with PHP?


2. Explain the steps to create a MySQL database using the CREATE DATABASE command.
3. How do you list all databases in MySQL?
4. What is the difference between CREATE DATABASE and USE DATABASE commands?
5. Write an SQL command to create a database named student_db.

5.2 Connecting to MySQL Database from a PHP Server

6. How do you establish a connection between PHP and MySQL?


7. Write a PHP script to connect to a MySQL database using mysqli_connect().
8. What are the differences between mysqli and PDO for database connection in PHP?
9. How do you check if a database connection was successful in PHP?
10. Write a PHP script to close a MySQL database connection.

5.3 Database Operations: Inserting Data, Retrieving Query Results

11. Write an SQL query to insert data into a users table with columns id, name, and email.
12. How do you execute an SQL INSERT statement in PHP? Provide an example.
13. What is the difference between mysqli_query() and mysqli_prepare() for inserting
data?
14. Write a PHP script to fetch all records from a MySQL table and display them in an
HTML table.
15. Explain the difference between fetch_assoc() and fetch_array() methods in PHP.

5.4 Update and Delete Operations on Table Data

16. How do you update a record in a MySQL table? Provide an SQL query example.
17. Write a PHP script to update a user's email based on their id.
18. What is the importance of using the WHERE clause in UPDATE and DELETE queries?
19. Write a SQL query to delete a record from the students table where id=5.
20. How do you handle SQL injection when updating or deleting data in PHP?
Additional Conceptual Questions

21. What is the purpose of the PRIMARY KEY in a MySQL table?


22. Explain the difference between VARCHAR and TEXT data types in MySQL.
23. What are the advantages of using prepared statements over normal queries?
24. How can you retrieve only specific columns from a MySQL table using a SELECT query?
25. What is indexing in MySQL, and how does it improve query performance?

You might also like