MY SQL
MY SQL
Answer: MySQL is an open-source Relational Database Management System (RDBMS) that stores data in
structured form.
Answer: 3306.
Answer: A FOREIGN KEY is a field that links one table to another by referencing the PRIMARY KEY of the
other table.
Answer: CHAR has a fixed length, whereas VARCHAR has a variable length.
Answer: It combines rows from two or more tables based on a related column.
Answer: DELETE removes specific rows, while TRUNCATE removes all rows but keeps the table structure.
Answer: It groups rows that have the same values in specified columns.
37. How do you delete all rows in a table without deleting the table itself?
Answer: Normalization is the process of organizing data to reduce redundancy and improve data integrity.
Answer:
MySQL is an open-source Relational Database Management System (RDBMS) based on Structured Query
Language (SQL). It is widely used to manage and store data for applications.
Features of MySQL:
Answer:
An RDBMS is a database management system that stores data in tables (rows and columns), where
relationships exist between different tables.
Answer:
SQL MySQL
SQL is a language used to interact with databases. MySQL is an RDBMS that uses SQL as its query language.
SQL is not software but a query standard. MySQL is database software.
Platform-independent. Specific implementation on platforms.
SQL is universal. MySQL is specific to its database system.
4. What are the basic SQL commands in MySQL? Explain with examples.
Answer:
SQL commands are categorized into:
Answer:
Primary Key: A column (or set of columns) that uniquely identifies each record in a table. It cannot
have NULL values.
Example:
Foreign Key: A column that references the Primary Key of another table to establish a relationship
between two tables.
Example:CREATE TABLE Orders (OrderID INT, EmpID INT, FOREIGN KEY (EmpID)
REFERENCES Employee(ID));
Answer:
Normalization is the process of organizing data to minimize redundancy and improve data integrity.
Types of Normalization:
1. 1NF (First Normal Form): Eliminate duplicate columns and ensure each column contains atomic
values.
2. 2NF (Second Normal Form): Meet 1NF and remove partial dependency.
3. 3NF (Third Normal Form): Meet 2NF and remove transitive dependency.
4. BCNF (Boyce-Codd Normal Form): A stricter version of 3NF.
Answer:
Create Database:
Delete Database:
Answer:
The SELECT statement is used to retrieve data from a table.
Syntax:
Example: SELECT Name, Salary FROM Employee WHERE Salary > 5000;
9. Explain the use of the JOIN clause in MySQL and its types.
Answer:
The JOIN clause is used to combine rows from two or more tables based on a related column.
Types of JOINs:
Example:
Answer:
The WHERE clause is used to filter records based on a condition.
Example:
Answer:
Example:
Answer:
Indexes are used to speed up data retrieval operations in a table.
Answer:
A transaction is a sequence of SQL commands that are executed as a single unit.
Example:
START TRANSACTION;
UPDATE Account SET Balance = Balance - 500 WHERE ID = 1;
COMMIT;
Answer:
Aggregate functions perform calculations on a set of values:
Example:
Answer:
The GROUP BY clause groups rows with the same values into summary rows.
Example: