{"id":19606751,"url":"https://github.com/learnwithfair/sql-database-documentation","last_synced_at":"2025-02-26T16:43:50.851Z","repository":{"id":237645096,"uuid":"794697084","full_name":"learnwithfair/sql-database-documentation","owner":"learnwithfair","description":"sql database documentation with [learnwithfair, Learn with fair, Rahatul Rabbi, Md Rahatul Rabbi ,rahatulrabbi]","archived":false,"fork":false,"pushed_at":"2024-05-02T09:51:12.000Z","size":1077,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-09T09:24:24.461Z","etag":null,"topics":["database","documentation","learn-with-fair","learnwithfair","rahatul-rabbi","rahatulrabbi","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/learnwithfair.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-05-01T19:00:13.000Z","updated_at":"2024-05-02T09:51:15.000Z","dependencies_parsed_at":"2024-05-02T22:38:21.342Z","dependency_job_id":null,"html_url":"https://github.com/learnwithfair/sql-database-documentation","commit_stats":null,"previous_names":["learnwithfair/sql-database-documentation"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsql-database-documentation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsql-database-documentation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsql-database-documentation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/learnwithfair%2Fsql-database-documentation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/learnwithfair","download_url":"https://codeload.github.com/learnwithfair/sql-database-documentation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240894531,"owners_count":19874830,"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","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":["database","documentation","learn-with-fair","learnwithfair","rahatul-rabbi","rahatulrabbi","sql"],"created_at":"2024-11-11T10:07:06.447Z","updated_at":"2025-02-26T16:43:50.828Z","avatar_url":"https://github.com/learnwithfair.png","language":null,"readme":"Thanks for visiting my GitHub account!\n\n\u003cimg src =\"https://cdn-icons-png.freepik.com/512/4248/4248443.png\" height = \"200px\" width = \"200px\"/\u003e **Structured Query Language(SQL)** is a standard database language used to access and manipulate data in databases. SQL was developed by IBM Computer Scientists in the 1970s. By executing queries SQL can create, update, delete, and retrieve data in databases like MySQL, Oracle, PostgreSQL, etc. Overall SQL is a query language that communicates with databases.\n\n## For Information\n\n- https://www.w3schools.com/sql/\n- https://www.geeksforgeeks.org/sql-tutorial/\n\n### [Code-Example](https://github.com/learnwithfair/sql-database)\n\n## Download Offline\n\n- Download the Full Source Code. visit -\u003e https://mega.nz/folder/oX9jXJAJ#Dh5dpdMGB5SZZ2Dsqe1E6g\n- Download Software. visit -\u003e https://mega.nz/file/EHUDDDrQ#HvsoZvjVc9UoLkCVfdDLT0KV0tZ93lR16C-geBGUtiM\n\n## Download Online\n\n- visit -\u003ehttps://www.microsoft.com/en-us/download/details.aspx?id=101064\n\n## SQL Overview\n\n|                        |\n| :--------------------: |\n|        Overview        |\n| ![sql](images/sql.png) |\n\n## Advance SQL Overview\n\n|                      |                      |\n| :------------------: | :------------------: |\n| ![sql](images/1.jpg) | ![sql](images/2.jpg) |\n| ![sql](images/3.jpg) | ![sql](images/4.jpg) |\n| ![sql](images/5.jpg) | ![sql](images/6.jpg) |\n| ![sql](images/7.jpg) | ![sql](images/8.jpg) |\n\n## Project Screenshot\n\n|                                                                                                  |                                                                                                |\n| :----------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------: |\n|                                            Primary-1                                             |                                           Primary-2                                            |\n|    ![primary-1](https://github.com/learnwithfair/sql-database/blob/main/screenshort/p-1.jpg)     |   ![primary-2](https://github.com/learnwithfair/sql-database/blob/main/screenshort/p-2.jpg)    |\n|                                         Intermediate-1.1                                         |                                        Intermediate-1.2                                        |\n| ![Intermediate-1](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-1.1.jpg) | ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-1.2.jpg) |\n|                                         Intermediate-2.1                                         |                                        Intermediate-2.2                                        |\n|  ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-2.1.jpg)  | ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-2.2.jpg) |\n|                                         Intermediate-3.1                                         |                                        Intermediate-3.2                                        |\n|  ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-3.1.jpg)  | ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-3.2.jpg) |\n|                                          Intermediate-4                                          |                                        Intermediate-5.1                                        |\n|   ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-4.jpg)   | ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-5.1.jpg) |\n|                                         Intermediate-5.2                                         |\n|  ![Intermediate](https://github.com/learnwithfair/sql-database/blob/main/screenshort/I-5.2.jpg)  |\n\n### Some SQL Query\n\n```bash\nuse pubs\n```\n\n## Task-1\n\n```bash\nselect * from titles;\nselect title, royalty from titles  where royalty between 12 and 24;\n```\n\n## Task-2\n\n```bash\nselect * from authors ;\nselect au_lname,state from authors where state='ca';\n```\n\n## Task-3\n\n```bash\nselect * from titles ;\nselect type , AVG(price) as avg_price from titles GROUP BY type HAVING AVG(price)\u003e15;\n```\n\n## Task-4\n\n```bash\nselect * from titles; --(title_id,pub_id)\nselect * from titleauthor; --(title_id,au_id)\nselect * from authors;  --(au_id)\nselect * from publishers;--(pub_id)\nselect title,au_fname +' '+au_lname as author_name,pub_name\n from authors join titleauthor on titleauthor.au_id=authors.au_id join titles\n on titleauthor.title_id= titles.title_id join publishers on titles.pub_id=publishers.pub_id;\n```\n\n## Task-5\n\n```bash\nselect au_lname,authors.city, pub_name,publishers.city from authors join publishers on authors.city=publishers.city;\n```\n\n## Task-6\n\n```bash\ncreate database shops;\n```\n\n## Task-7\n\n```bash\nuse shops;\n\n--CustomerAndSuppliers Table Creating Start\nCREATE TABLE CustomerAndSuppliers\n(\ncusl_id CHAR (6) PRIMARY KEY CHECK (cusl_id LIKE '[CS][0-9][0-9][0-9][0-9][0-9]'),\ncusl_fname CHAR(15) NOT NULL,\ncusl_lname VARCHAR (15),\ncusl_address TEXT,\ncusl_telno CHAR (12) CHECK (cusl_telno LIKE '[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),\ncusl_city CHAR (17) DEFAULT 'Lalmonirhat',\nsales_amnt MONEY CHECK (sales_amnt\u003e=0),\nproc_amnt MONEY CHECK (proc_amnt\u003e=0)\n);\n\n--Items Table Creating Start\nCREATE TABLE Items\n(\nitem_id CHAR (6) PRIMARY KEY CHECK (item_id LIKE '[P][0-9][0-9][0-9][0-9][0-9]'),\nitem_name CHAR(12),\nitem_category VARCHAR (10),\nitem_price FLOAT(12) check(item_price\u003e=0),\nitem_qoh INT CHECK (item_qoh\u003e=0),\nitem_last_sold DATE DEFAULT getdate(),\n);\n\n--Transactions Table Creating Start\nCREATE TABLE Transactions\n(\ntran_id CHAR (10) PRIMARY KEY CHECK (tran_id LIKE '[T][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]'),\nitem_id CHAR(6) FOREIGN KEY(item_id) REFERENCES Items(item_id),\ncusl_id CHAR (6) FOREIGN KEY(cusl_id) REFERENCES CustomerAndSuppliers(cusl_id),\ntran_type CHAR(1),\ntran_quantity INT CHECK (tran_quantity\u003e=0),\ntran_date DATETIME DEFAULT getdate(),\n);\n```\n\n## Taks-8\n\n```bash\n--CustomerAndSuppliers Table Insert Start\ninsert into CustomerAndSuppliers\n(cusl_id,cusl_fname,cusl_lname,cusl_address,cusl_telno,cusl_city,sales_amnt,proc_amnt) VALUES\n('C00001','Iqbal','Hossain','221/B Dhanmondi','017-00000000','Dhaka',0,0);\n\ninsert into CustomerAndSuppliers\n(cusl_id,cusl_fname,cusl_lname,cusl_address,cusl_telno,cusl_city,sales_amnt,proc_amnt) VALUES\n('C00002','RAHAT','KABIR','221/B Dhanmondi','017-00000000','Dhaka',0,0);\n\n\n--CustomerAndSuppliers Table Display Start\nSELECT * from CustomerAndSuppliers;\n\n--CustomerAndSuppliers Table value Delete Start\ndelete from CustomerAndSuppliers;\n\n--CustomerAndSuppliers Table Delete Start\nDROP TABLE CustomerAndSuppliers;\n\n\n\n--Items Table Inserting Start\n\ninsert into Items\n(item_id,item_name,item_category,item_price,item_qoh) VALUES\n('P00005','RAHATUL','laptop','5241.2','45');\n\ninsert into Items\n(item_id,item_name,item_category,item_price,item_qoh) VALUES\n('P00002','RABBI','Phone','5241.2','45');\n--Items Table Display Start\nSELECT * from Items;\n\n--Items Table value Delete Start\ndelete from Items;\n\n--Item Table Delete Start\nDROP TABLE Items;\n```\n\n## Task-9\n\n```bash\nCREATE PROCEDURE itemsProcedure\nAS\nBEGIN\nselect \"Catagory\"=item_category,\"Total number of items\"=sum(item_qoh),\"Average Price\"=avg(item_price) from Items group by item_category\nEND\nEXEC itemsProcedure\n\nselect * from sys.procedures;\ndrop procedure itemsProcedure;\n```\n\n## Task-10\n\n```bash\nCREATE PROC storeProcedure @category_name char(15),@price_value money\nAS\nBEGIN\n DECLARE @price money\n select @price=avg(item_price) from items where item_category=@category_name;\n     while  @price\u003c@price_value\n        BEGIN\n          update items set item_price=item_price+item_price*.1 where item_category=@category_name;\n          select @price=avg(item_price) from items where item_category=@category_name;\n        END\nEND\nEXEC storeProcedure 'Phone',5842.1\nselect avg(item_price) as avg_item_price from items where item_category='Phone';\nselect * from items\n\ndrop procedure storeProcedure;\n```\n\n## Optional\n\n#### Transactions Table Inserting Start\n\n```bash\ninsert into Transactions\n(tran_id,item_id,cusl_id,tran_type,tran_quantity) VALUES\n('T000052149','P00005','C00001','S',12);\n\ninsert into Transactions\n(tran_id,item_id,cusl_id,tran_type,tran_quantity) VALUES\n('T000052142','P00002','C00002','O',12);\n```\n\n#### Transactions Table Display Start\n\n```bash\nselect * from Transactions;\n```\n\n#### Transactions Table value Delete Start\n\n```bash\ndelete from Transactions;\n```\n\n#### Transactions Table Delete Start\n\n```bash\nDROP TABLE Transactions;\n```\n\n## Follow Me\n\n\u003cimg src =\"https://www.edigitalagency.com.au/wp-content/uploads/Facebook-logo-blue-circle-large-transparent-png.png\" height=\"15px\" width=\"15px\"/\u003e [Facebook](http://facebook.com/learnwithfair), \u003cimg src =\"https://image.similarpng.com/very-thumbnail/2021/10/Youtube-icon-design-on-transparent-background-PNG.png\" height=\"20px\" width=\"20px\"/\u003e [Youtube](http://youtube.com/@learnwithfair), \u003cimg src =\"https://i.pinimg.com/originals/fa/ea/02/faea02f412415becfb4939d2b6431c28.jpg\" height=\"15px\" width=\"15px\"/\u003e [Instagram](http://instagram.com/learnwithfair)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnwithfair%2Fsql-database-documentation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flearnwithfair%2Fsql-database-documentation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flearnwithfair%2Fsql-database-documentation/lists"}