{"id":31796421,"url":"https://github.com/devopswithalii/mysql","last_synced_at":"2025-10-10T20:48:33.834Z","repository":{"id":316295287,"uuid":"1062794780","full_name":"DevOpsWithAlii/MySQL","owner":"DevOpsWithAlii","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-23T19:15:22.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-23T20:29:12.830Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DevOpsWithAlii.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-23T18:31:19.000Z","updated_at":"2025-09-23T19:15:26.000Z","dependencies_parsed_at":"2025-09-23T20:39:17.964Z","dependency_job_id":null,"html_url":"https://github.com/DevOpsWithAlii/MySQL","commit_stats":null,"previous_names":["devopswithalii/mysql"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/DevOpsWithAlii/MySQL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevOpsWithAlii%2FMySQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevOpsWithAlii%2FMySQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevOpsWithAlii%2FMySQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevOpsWithAlii%2FMySQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DevOpsWithAlii","download_url":"https://codeload.github.com/DevOpsWithAlii/MySQL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DevOpsWithAlii%2FMySQL/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279005268,"owners_count":26083864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-10T20:48:21.677Z","updated_at":"2025-10-10T20:48:33.829Z","avatar_url":"https://github.com/DevOpsWithAlii.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## **1. Introduction to SQL \u0026 DBMS**\n\n- **What is SQL?**\n  - SQL stands for **Structured Query Language**.\n  - It is a standardized language used to **store, manipulate, and retrieve data** in databases.\n  - SQL works with various DBMS (Database Management Systems) like MySQL, Oracle, SQL Server, and MongoDB.\n\n- **What is MySQL?**\n  - MySQL is a popular open-source DBMS that uses SQL.\n\n***\n\n## **2. Installation and Setup**\n\n- Install **XAMPP** (for running MySQL server) and **MySQL Workbench** (GUI client).\n- Start Apache and MySQL from XAMPP, then use MySQL Workbench or CLI for running queries.\n\n***\n\n## **3. Basic Database Concepts**\n\n- **Database**: Organized storage area for related data (like a computerized register).\n- **Table**: Structure to store data in rows and columns.\n- **Field/Column**: Individual attribute (e.g., Name, Age).\n- **Record/Row**: One complete set of data in a table.\n\n***\n\n## **4. Creating/Selecting a Database**\n\n```sql\n-- Create a database named 'company'\nCREATE DATABASE company;\n\n-- Select database for use\nUSE company;\n\n-- Show all databases\nSHOW DATABASES;\n\n-- Drop a database\nDROP DATABASE company;\n```\n\n***\n\n## **5. Creating a Table**\n\n```sql\nCREATE TABLE employee_info (\n    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,  -- Auto incrementing primary key\n    emp_name VARCHAR(30) NOT NULL,\n    address VARCHAR(255) NOT NULL,\n    city VARCHAR(20) NOT NULL,\n    age INT NOT NULL,\n    doj DATE NOT NULL,         -- Date of joining\n    designation VARCHAR(20) NOT NULL,\n    salary DECIMAL(10, 2) NOT NULL,\n    mobile VARCHAR(10) NOT NULL\n);\n\n-- See structure of table\nDESCRIBE employee_info;\n```\n\n***\n\n## **6. Insert, View, and Manipulate Data**\n\n### **Insert Data**\n```sql\nINSERT INTO employee_info \n(emp_name, address, city, age, doj, designation, salary, mobile) \nVALUES\n('Kamlesh', 'Ajmer', 'Jaipur', 35, '2008-05-04', 'Programmer', 3000.50, '9810012345'),\n('Sunil', 'Jodhpur', 'Udaipur', 41, '2012-11-20', 'Manager', 6000.00, '9820012345');\n```\n\n### **View Data**\n```sql\n-- See all data\nSELECT * FROM employee_info;\n\n-- See selected columns only\nSELECT emp_name, mobile FROM employee_info;\n```\n\n***\n\n## **7. Filtering Data**\n\n### **WHERE Clause**\n```sql\nSELECT * FROM employee_info WHERE designation = 'Programmer';\n```\n\n### **AND, OR Operators**\n```sql\nSELECT * FROM employee_info WHERE designation = 'Programmer' AND city = 'Jaipur';\nSELECT * FROM employee_info WHERE city = 'Jaipur' OR salary = 4200;\n```\n\n### **NOT, LIKE, IN, BETWEEN Operators**\n```sql\nSELECT * FROM employee_info WHERE city NOT LIKE 'Jaipur';\nSELECT * FROM employee_info WHERE city IN ('Ajmer', 'Udaipur');\nSELECT * FROM employee_info WHERE salary BETWEEN 3000 AND 6000;\n```\n\n***\n\n## **8. Updating and Deleting Data**\n\n### **Update Data**\n```sql\nUPDATE employee_info SET address = 'New Ajmer' WHERE id = 2;\nUPDATE employee_info SET salary = 6500 WHERE id = 2;\n```\n\n### **Delete Data**\n```sql\nDELETE FROM employee_info WHERE id = 1;\n```\n\n***\n\n## **9. Table Alteration**\n\n### **Add Column**\n```sql\nALTER TABLE employee_info ADD email VARCHAR(50);\n```\n### **Delete Column**\n```sql\nALTER TABLE employee_info DROP COLUMN email;\n```\n### **Change Column**\n```sql\nALTER TABLE employee_info MODIFY salary DECIMAL(12,2);\n```\n### **Drop Table**\n```sql\nDROP TABLE employee_info;\n```\n\n***\n\n## **10. Sorting and Limiting Data**\n\n```sql\nSELECT * FROM employee_info ORDER BY salary DESC;  -- Sort Descending\nSELECT * FROM employee_info ORDER BY emp_name ASC; -- Sort Ascending\nSELECT * FROM employee_info LIMIT 3;               -- Limit to top 3 rows\n```\n\n***\n\n## **11. Aggregate Functions**\n\n```sql\nSELECT COUNT(*) FROM employee_info;       -- Number of employees\nSELECT SUM(salary) FROM employee_info;    -- Total salary\nSELECT AVG(salary) FROM employee_info;    -- Average salary\nSELECT MIN(salary) FROM employee_info;    -- Minimum salary\nSELECT MAX(salary) FROM employee_info;    -- Maximum salary\n```\n\n***\n\n## **12. Joins (Combining Data from Multiple Tables)**\n\n#### **Creating Second Table (Department)**\n```sql\nCREATE TABLE department (\n    department_id INT PRIMARY KEY,\n    department_name VARCHAR(20)\n);\n\n-- Add some departments\nINSERT INTO department VALUES (1, 'HR'), (2, 'IT'), (3, 'Accounts');\n```\n\n#### **Adding Department ID to Employee Table**\n```sql\nALTER TABLE employee_info ADD department_id INT;\nALTER TABLE employee_info ADD FOREIGN KEY (department_id) REFERENCES department(department_id);\n```\n\n#### **Inner Join Example**\n```sql\nSELECT e.emp_name, d.department_name \nFROM employee_info e\nINNER JOIN department d ON e.department_id = d.department_id;\n```\n\n***\n\n## **13. Constraints**\n\n- **NOT NULL**: Prevents empty values\n- **UNIQUE**: No duplicates\n- **DEFAULT**: Adds a default value\n- **CHECK**: Ensures values meet criteria\n- **PRIMARY KEY**: Unique, not null, identifier\n- **FOREIGN KEY**: Ensures referential integrity\n\n**Example with Constraints:**\n```sql\nCREATE TABLE student (\n    student_id INT PRIMARY KEY,\n    name VARCHAR(50) NOT NULL,\n    email VARCHAR(100) UNIQUE,\n    class VARCHAR(10) DEFAULT 'NA',\n    age INT CHECK(age \u003e= 3)\n);\n```\n\n***\n\n## **14. Grouping Data**\n\n```sql\nSELECT designation, COUNT(*) AS count FROM employee_info GROUP BY designation;\nSELECT city, SUM(salary) FROM employee_info GROUP BY city HAVING SUM(salary)\u003e10000;\n```\n\n***\n\n## **15. Backup, Copy, Export**\n\n- Copy data from one table to another:\n```sql\nCREATE TABLE employee_backup LIKE employee_info;\nINSERT INTO employee_backup SELECT * FROM employee_info;\n```\n\n- Export/Import via .*csv* or Excel using GUI tools.\n\n***\n\n\n[VIDEO](https://www.youtube.com/watch?v=7wj7UEdLI6U)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevopswithalii%2Fmysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevopswithalii%2Fmysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevopswithalii%2Fmysql/lists"}