SQL
SQL
On
MY SQL
A project report submitted in partial fulfilment of the requirements for award of the
Degree of
BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND ENGINEERING
Submitted by
2022-2026
CERTIFICATE
This is to certify that the project report entitled “MY SQL” is a Bonafide record
of work carried out by the KILARI VYSHNAVI (22KP1A0558)
carried out the research under the super vision. Certified further, that to the best of
knowledge the work reported here in does not form part of any other Project
report or dissertation on the basis of which a degree of award was conferred on an
earlier occasion on this or any other candidates.
It’s our pleasure to thank all the faculty members of CSE department for extending
their constant co-operation and support during our stay in NRIIT.
Our heartiest thanks to our beloved parents who are well behind us for all our success
as well as achievements.
Finally, we thank all our friends who helped either directly or indirectly to achieve
our GOAL.
NAME ROLL NO
KILARI VYSHNAVI 22KP1A0558
DECLARATION
We hereby declare that the work which is being presented in the Dissertation Entitled
“MY SQL” submitted towards the partial of fulfillment of requirements for the award
of the degree in Bachelor of Technology and authentic record in Department of
Computer Science And Engineering at NRI Institute of Technology, Guntur.
The matter embodied in this dissertation report has not been submitted
by us for the award of any other degree. Further the technical details
furnished in the various chapters in this report are purely relevant to the
above project and there is no deviation from the theoretical point of
view for design, development and implementation.
NAME ROLL NO
K.VYSHNAVI 22KP1A0558
CONTENTS
- Types of joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, CROSS JOIN
- Using GROUP BY and aggregate functions (COUNT, SUM, AVG, MAX, MIN)
- Event scheduling
This structure provides a solid foundation for learning MySQL from basic to
advanced concepts.
Introduction
1.Databases and MySQL :
What is a Database?
A database is an organized collection of data that is structured for efficient retrieval and
modification.
Example: A library database with tables for books, authors, and borrowers.
WHERE Clause
Filtering data with conditions.
Example:
sql
SELECT * FROM students WHERE age > 14;
3. Data Manipulation
Statement
Modifying existing data.
Example:
sql
UPDATE students SET grade = '11th' WHERE name = 'John Doe';
DELETE Statement
Removing data from a table.
Example:
Sql
DELETE FROM students WHERE age < 15;
Example:
Sql
CREATE TABLE orders (
order_id INT PRIMARY KEY,
customer_id INT,
FOREIGN KEY (customer_id) REFERENCES customers(customer_id)
);
NULL, UNIQUE, DEFAULT
Enforcing constraints on columns.
Example:
sql
CREATE TABLE employees (
emp_id INT NOT NULL,
emp_name VARCHAR(100) UNIQUE,
hire_date DATE DEFAULT CURRENT_DATE
);
INDEXES
Speeding up data retrieval using indexes.
Example:
sql
CREATE INDEX idx_name ON students (name);
ORDER BY Clause
Sorting results by one or more columns.
Example:
sql
SELECT * FROM students ORDER BY age DESC;
LIMIT Clause
Limiting the number of rows returned.
Example:
sql
SELECT * FROM students LIMIT 5;
Example:
sql
SELECT AVG(age) FROM students;
String Functions
Functions like CONCAT(), UPPER(), LOWER(), LENGTH().
Example:
sql
SELECT CONCAT(first_name, ' ', last_name) FROM employees;
ate Functions
Functions like NOW(), DATE(), YEAR(), MONTH(), DAY().
Example:
sql
SELECT YEAR(hire_date) FROM employees;
Subqueries
Queries within queries, often used in WHERE or FROM clauses.
Example:
sql
SELECT name FROM students WHERE id IN (SELECT student_id FROM
course_enrollments WHERE course_id = 101);
7. Database Normalization
First Normal Form (1NF)
Ensuring each column contains atomic values, and each record is unique.
Example:
sql
CREATE TABLE employees (
id INT PRIMARY KEY,
name VARCHAR(100),
department VARCHAR(100)
);
Second Normal Form (2NF)
Removing partial dependency (dependencies on part of the primary key).
ACID Properties
Atomicity: All or nothing.
Consistency: Database must transition from one valid state to another.
Isolation: Transactions do not affect each other.
Durability: Changes are permanent.
Using BEGIN, COMMIT, and ROLLBACK**
Example:
sql
BEGIN;
UPDATE account SET balance = balance - 100 WHERE account_id = 1;
UPDATE account SET balance = balance + 100 WHERE account_id = 2;
COMMIT;
Example:
sql
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT ON school.* TO 'new_user'@'localhost';
Securing Connections (SSL/TLS)
Setting up encrypted connections to MySQL.
Backing Up and Restoring Databases
Using mysqldump for backups.
Example:
bash
mysqldump -u root -p school > school_backup.sq
Database Partitioning
Partitioning large tables to improve performance.
Conclusion :
This syllabus covers a broad range of MySQL topics, from the basics of database creation to
advanced performance tuning and security. By following this roadmap, you will be able to
build, maintain, and optimize MySQL databases effectively. Practice through examples and
real-world projects will solidify your understanding of MySQL concepts. PROFESSOR &
HOD