{"id":24044583,"url":"https://github.com/furqanhun/dbms-labmanual","last_synced_at":"2026-06-04T23:31:14.913Z","repository":{"id":245317399,"uuid":"817893915","full_name":"FurqanHun/dbms-labmanual","owner":"FurqanHun","description":"This repo includes documention of MySQL quries used for my DBMS Lab Manual Tasks","archived":false,"fork":false,"pushed_at":"2024-06-20T17:07:16.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-26T09:14:17.941Z","etag":null,"topics":["dbms","mysql","sql"],"latest_commit_sha":null,"homepage":"","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/FurqanHun.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}},"created_at":"2024-06-20T16:56:06.000Z","updated_at":"2024-06-20T17:11:29.000Z","dependencies_parsed_at":"2024-06-21T11:11:47.456Z","dependency_job_id":"707549d4-f83a-4753-b08a-b7dda6146177","html_url":"https://github.com/FurqanHun/dbms-labmanual","commit_stats":null,"previous_names":["furqanhun/dbms-labmanual"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/FurqanHun/dbms-labmanual","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FurqanHun%2Fdbms-labmanual","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FurqanHun%2Fdbms-labmanual/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FurqanHun%2Fdbms-labmanual/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FurqanHun%2Fdbms-labmanual/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FurqanHun","download_url":"https://codeload.github.com/FurqanHun/dbms-labmanual/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FurqanHun%2Fdbms-labmanual/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33924832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-04T02:00:06.755Z","response_time":64,"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":["dbms","mysql","sql"],"created_at":"2025-01-08T23:32:20.831Z","updated_at":"2026-06-04T23:31:14.898Z","avatar_url":"https://github.com/FurqanHun.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 style=\"text-align: center;\"\u003eLab Tasks DBMS - MySQL\u003c/h1\u003e\n\nFollowing are the quries i used in lab manual tasks, i have also included some additional queries that i didn't do in the lab manual but are relevant to the topic.\n\n# Table Of Content\n- [Lab 01 - Implementation of DDL commands](#lab-01)\n- [Lab 02 - Implementation of DML commands](#lab-02)\n- [Lab 03 - Implementation of Different Types of Operators](#lab-03)\n- [Lab 04 - Implementation of Different Types of Joins](#lab-04)\n- [Lab 05 - Implementation of Subqueries](#lab-05)\n- [Lab 06 - Implementation of Count, Min, Sum](#lab-06)\n- [Lab 07 - Implementation of In, Between, Aliases](#lab-07)\n- [Lab 08 - Implementation of Union](#lab-08)\n- [Lab 09 - Implementation of MIN, MAX](#lab-09)\n- [Lab 10 - Implementation of Like, Wildcards](#lab-10)\n\n---\n\n# Lab 01\nImplementation of DDL commands of SQL\n- Create a table\n- Alter table\n- Drop Table\n\n## 1. Create a table\n```sql\nCREATE TABLE students (\n    id INT AUTO_INCREMENT PRIMARY KEY,\n    name VARCHAR(50) NOT NULL,\n    age INT NOT NULL\n);\n```\n\n## 2. Alter table\n```sql\nALTER TABLE students\nADD COLUMN email VARCHAR(100);\n```\n\n```sql\nALTER TABLE students\nCHANGE COLUMN age student_age INT;\n```\n\n## 3. Drop Table\n``` sql\nDROP TABLE students;\n```\n---\n# Lab 02\nImplementation of DML commands of SQL\n- Insert\n- Update\n- Delete\n\n## 1. Insert Data\n\n```sql\nINSERT INTO students (name, student_age, email)\nVALUES ('Furqan', 21, 'qan@thisdoesnotexist.com');\n```\n\n## 2. Update Data\n\n```sql\nUPDATE students\nSET student_age = 20, email = 'qan@stilldoesntexist.com'\nWHERE id = 1;\n```\n\n## 3. Delete Data\n\n```sql\nDELETE FROM students\nWHERE id = 1;\n```\n---\n\n# Lab 03\nImplementation of different types of Operators in SQL\n- Arithmetic Operators\n- Logical Operators\n- Comparison Operator\n\n## 1. Arithmetic Operators\n\n- Adding a value to the `student_age` column:\n\n```sql\nSELECT name, student_age, student_age + 1 AS age_next_year\nFROM students;\n```\n\n- Calculating the product of two columns:\n\n```sql\nSELECT id, name, student_age, student_age * 2 AS double_age\nFROM students;\n```\n\n## 2. Logical Operators\n\n- Selecting students who are older than 18 and younger than 25:\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age \u003e 18 AND student_age \u003c 25;\n```\n- Selecting students whose name starts with 'J' or are older than 21:\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE name LIKE 'J%' OR student_age \u003e 21;\n```\n## 3. Comparison Operators\n\n- Selecting students who are exactly 20 years old:\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age = 20;\n```\n\n- Selecting students who are not 20 years old:\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age != 20;\n```\n\n- Selecting students who are older than 18:\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age \u003e 18;\n```\n\n---\n\n# Lab 04\nImplementation of different types of joins\n- Inner join\n- Left join\n- Right join\n\nFirst lets create a table called `courses`\n```sql\nCREATE TABLE courses (\n    course_id INT AUTO_INCREMENT PRIMARY KEY,\n    course_name VARCHAR(50) NOT NULL,\n    student_id INT\n);\n\nINSERT INTO courses (course_name, student_id)\nVALUES\n    ('Pirate Training', 2),  -- Luffy\n    ('Swordsmanship', 3),    -- Zoro\n    ('Software Engineering', 1); -- Furqan\n```\n\n## 1. Inner Join\n\n```sql\nSELECT students.name, students.student_age, courses.course_name\nFROM students\nINNER JOIN courses ON students.id = courses.student_id;\n```\n\n## 2. Left Join\n\n```sql\nSELECT students.name, students.student_age, courses.course_name\nFROM students\nLEFT JOIN courses ON students.id = courses.student_id;\n```\n\n## 3. Right Join\n\n```sql\nSELECT students.name, students.student_age, courses.course_name\nFROM students\nRIGHT JOIN courses ON students.id = courses.student_id;\n```\n---\n\n# Lab 05\nStudy and implementation of Sub queries\n- Select\n- Where\n- From\n\n## 1. Select\n\n```sql\nSELECT name, student_age,\n       (SELECT COUNT(*) \n        FROM courses \n        WHERE courses.student_id = students.id) AS course_count\nFROM students;\n```\n\n## 2. Where\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE id IN (SELECT student_id \n             FROM courses \n             WHERE course_name = 'Pirate Training');\n```\n\n## 3. From\n\n```sql\nSELECT course_name, AVG(student_age) AS avg_age\nFROM (SELECT students.name, students.student_age, courses.course_name\n      FROM students\n      INNER JOIN courses ON students.id = courses.student_id) AS course_students\nGROUP BY course_name;\n```\n---\n\n# Lab 06\n\nImplementation of\n- Count\n- Min\n- Sum\n\nBefore we continue lets add more data in the databse as i realized we didnt have enough data to work with in the previous labs.\n\n```sql\n-- Insert more data into the students table\nINSERT INTO students (name, student_age, email)\nVALUES \n    ('Nami', 18, 'nami@navigator.com'),\n    ('Usopp', 19, 'usopp@sniper.com'),\n    ('Robin', 30, 'robin@archaeologist.com'),\n    ('Chopper', 17, 'chopper@doctor.com'),\n    ('Brook', 90, 'brook@musician.com'),\n    ('Franky', 36, 'franky@shipwright.com');\n\n-- Insert more data into the courses table\nINSERT INTO courses (course_name, student_id)\nVALUES\n    ('Navigation', 4),  -- Nami\n    ('Sniping', 5),     -- Usopp\n    ('History', 6),     -- Robin\n    ('Medical Training', 7),  -- Chopper\n    ('Music', 8),             -- Brook\n    ('Engineering', 9),       -- Franky\n    ('Swordsmanship', 1),     -- Furqan, adding Furqan to Swordsmanship as well\n    ('Cooking', 2),           -- Adding Luffy to Cooking (ifykyk)\n    ('Navigation', 3);        -- Adding Zoro to Navigation (lol)\n```\n## 1. Count\n\n```sql\nSELECT COUNT(*) AS total_students\nFROM students;\n```\n\n## 2. Min\n\n```sql\nSELECT MIN(student_age) AS youngest_student\nFROM students;\n```\n\n## 3. Sum\n\n```sql\nSELECT SUM(student_age) AS total_age\nFROM students;\n```\n---\n\n# Lab 07\n\nImplementation of\n- In\n- Between\n- Aliases\n\n## 1. In\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age IN (19, 20, 21);\n```\n## 2. Between\n\n```sql\nSELECT name, student_age\nFROM students\nWHERE student_age BETWEEN 18 AND 25;\n```\n\n## 3. Aliases\n\n```sql\nSELECT name AS student_name, student_age AS age\nFROM students;\n```\n\n---\n\n# Lab 08\nImplementation of\n- Union\n\n## 1. Union\n\n```sql\nSELECT name\nFROM students\nJOIN courses ON students.id = courses.student_id\nWHERE course_name = 'Swordsmanship'\n\nUNION\n\nSELECT name\nFROM students\nJOIN courses ON students.id = courses.student_id\nWHERE course_name = 'Navigation';\n```\n\n# Union All\n\n```sql\nSELECT name\nFROM students\nJOIN courses ON students.id = courses.student_id\nWHERE course_name = 'Swordsmanship'\n\nUNION ALL\n\nSELECT name\nFROM students\nJOIN courses ON students.id = courses.student_id\nWHERE course_name = 'Navigation';\n```\n\n---\n\n# Lab 09\nImplementation of\n- MIN\n- MAX\n\n## 1. MIN\n\n```sql\nSELECT MIN(student_age) AS min_age\nFROM students;\n```\n\n## 2. MAX\n\n```sql\nSELECT MAX(student_age) AS max_age\nFROM students;\n```\n\n---\n\n# Lab 10\nImplementation of\n- Like\n- Wildcards\n\n## 1. Like\n\n```sql\nSELECT name\nFROM students\nWHERE name LIKE 'L%';\n```\n\n## 2. Wildcards\n\n```sql\nSELECT name\nFROM students\nWHERE name LIKE '_o%';\n```\n\n---\n\n\u003ch1 style=\"text-align: center;\"\u003eTHE END\u003c/h1\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurqanhun%2Fdbms-labmanual","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffurqanhun%2Fdbms-labmanual","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffurqanhun%2Fdbms-labmanual/lists"}