{"id":20040622,"url":"https://github.com/muhammedahmetsekerci/cs50-sql-final-project","last_synced_at":"2025-09-20T09:31:02.427Z","repository":{"id":223585421,"uuid":"760962192","full_name":"muhammedahmetsekerci/CS50-SQL-FINAL-PROJECT","owner":"muhammedahmetsekerci","description":"CS50 SQL Final Project","archived":false,"fork":false,"pushed_at":"2024-08-29T07:24:02.000Z","size":194,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-13T10:48:07.379Z","etag":null,"topics":["cs50","cs50sql","cs50sql-final-project","sql","sqlite","sqlite3"],"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/muhammedahmetsekerci.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-02-21T01:23:42.000Z","updated_at":"2024-08-29T07:24:06.000Z","dependencies_parsed_at":"2024-11-13T10:43:15.282Z","dependency_job_id":"2e45f609-26e3-4656-bc74-2b2b3f3e07cf","html_url":"https://github.com/muhammedahmetsekerci/CS50-SQL-FINAL-PROJECT","commit_stats":null,"previous_names":["muhammedahmetsekerci/cs50-sql-final-project"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammedahmetsekerci%2FCS50-SQL-FINAL-PROJECT","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammedahmetsekerci%2FCS50-SQL-FINAL-PROJECT/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammedahmetsekerci%2FCS50-SQL-FINAL-PROJECT/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muhammedahmetsekerci%2FCS50-SQL-FINAL-PROJECT/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muhammedahmetsekerci","download_url":"https://codeload.github.com/muhammedahmetsekerci/CS50-SQL-FINAL-PROJECT/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233648595,"owners_count":18708225,"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":["cs50","cs50sql","cs50sql-final-project","sql","sqlite","sqlite3"],"created_at":"2024-11-13T10:43:03.905Z","updated_at":"2025-09-20T09:31:02.419Z","avatar_url":"https://github.com/muhammedahmetsekerci.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# CS50-SQL-FINAL-PROJECT\n\u003ca href=\"https://drive.google.com/file/d/1hMLdIjNCOwN-NCuetewx-gsN5mixDDKY/view?usp=drive_link\"\u003eCertificate\u003c/a\u003e\n\n[![Repo](https://img.shields.io/badge/View-CS50_SQL_Repo-181717?logo=github\u0026logoColor=white)](https://github.com/muhammedahmetsekerci/CS50-SQL) \u003cbr\u003e\n▶️ [How to Set Up CS50 – My Video](https://youtu.be/bpUzYV2dnRA) \u003cbr\u003e\n\n# Design Document\n\nBy Muhammed Ahmet Sekerci\n\nVideo overview: https://www.youtube.com/watch?v=4YJtizONyW8\n\n## Scope\n\nThis database is designed to easily store the data of a technology company's customers, employees and orders. As such, included in the database's scope is:\n\n* **Customers** Contains customer identification information and deletion information\n* **Trademarks** Includes product brands\n* **Categories** Includes product categories\n* **Products** It Product information is kept here\n* **Cities** cities are found in this table\n* **Shops**  Information about the store is kept in this table.\n* **Departments** department information is found in this table\n* **JobPositions** job positions are found in this table\n* **Employees** Basic information of the employees + job position information, department information, store information about which store they are in, starting date, salary, number of leaves and working status information are included in this table.\n* **Indemnity** Employee compensation information is included in this table.\n* **Annual_Leave** The leaves used by employees are listed in this table.\n* **Orders** The store where the order was placed, the employee who sold it and the customer who purchased it, and the date it was sold are included in this table.\n* **Order_Item** When an order is placed, the basket information for that order is included in this table.\n\n* Other elements provided by a tech store are excluded example;\n-customer point\n-employee bonus\n-Extra information for each shop\n\n## Functional Requirements\n\n**Customers**\nCan create orders, list them, and return orders.\nCan view information about products and stores\n\n## Representation\n\n### Entities\n\n**Customers:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Is the data type. There is always an ID of the customer \u003ccode\u003e PRIMARY KEY \u003c/code\u003e. ID number will be added automatically \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e Customer name should not exceed 40 characters \u003ccode\u003e VARCHAR(40). \u003c/code\u003e This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"surname\"\u003c/code\u003e customer surname information. Cannot exceed 20 characters \u003ccode\u003eVARCHAR(20)\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"phoneNumber\"\u003c/code\u003e represents the phone number. Because there are variable length \u003ccode\u003eTEXT\u003c/code\u003e. This line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. Must contain only numbers \u003ccode\u003eCHECK(\"phoneNumber\" GLOB '*[0-9]*')\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"email\"\u003c/code\u003e because it will contain special characters \u003ccode\u003eTEXT\u003c/code\u003e. This line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e  Must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. @ sign control \u003ccode\u003eCHECK(\"email\" LIKE '%@%'\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"address\"\u003c/code\u003e address information. Should not exceed 70 characters \u003ccode\u003eNVARCHAR(70)\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"deleted\"\u003c/code\u003e This line will be used if the customer is deleted. There will be only numbers \u003ccode\u003eINTEGER\u003c/code\u003e. It should be automatically 0 when the customer first becomes a member, it has not been deleted yet \u003ccode\u003eDEFAULT 0\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Only deleted or not deleted will be checked 0 or 1 \u003ccode\u003eCHECK(\"deleted\" BETWEEN 0 AND 1).\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n**Trademarks:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Every brand should have a unique identity \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e indicates the brand name. Brand name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Categories:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each category should be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003eindicates the category name. Category name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Category name must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Products:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e product indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Every product should be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e indicates the product name. Product name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"stock\"\u003c/code\u003e Indicates the number of stocks. The number of stocks must be numerical \u003ccode\u003eINTEGER\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Stock - should not be \u003ccode\u003eCHECK(\"stock\" \u003e= 0)\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"categoryId\"\u003c/code\u003e Specifies the category number. Category number must be numeric \u003ccode\u003eINTEGER\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Categories' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"trademarkId\"\u003c/code\u003e Specifies the trademark number. Trademark number must be numeric \u003ccode\u003eINTEGER\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Trademarks' table is restricted. \u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"price\"\u003c/code\u003e indicates the product price. Fee must be numerical \u003ccode\u003eNUMERIC\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Fee - should not be \u003ccode\u003eCHECK(\"price\" \u003e 0)\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"productStatus\"\u003c/code\u003e Indicates the status of the product. Status should not exceed 20 characters \u003ccode\u003eVARCHAR(20)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The product status should include some options \u003ccode\u003eCHECK(\"productStatus\" IN ('sale','not on sale','stock expected')\u003c/code\u003e. \u003c/li\u003e \u003cbr\u003e\nA brand cannot have more than one product with the same name. \u003ccode\u003e CONSTRAINT unique_product_trademark UNIQUE (\"trademarkId\", \"name\").\u003c/code\u003e\n\u003c/ul\u003e\n\n**Cities:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e Shows city ID number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each city number must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e Specifies the city name. City name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003c/ul\u003e\n\n**Shops:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e Shows Shop ID number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each shop number must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e Specifies the shop name. Shop name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"cityId\"\u003c/code\u003e Indicates the city number where it is located. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Cities' table is restricted.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"shopStatus\"\u003c/code\u003e Indicates shop status. Status should not exceed 12 characters \u003ccode\u003eVARCHAR(12)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Shop status should contain some options \u003ccode\u003eCHECK(\"shopStatus\" IN('active', 'repair','not active')\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Departments:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each department should be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e Specifies the department name. Department name should not exceed 30 characters \u003ccode\u003eVARCHAR(30)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Department name must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**JobPositions:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e Every job position should be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e Specifies the job position name. job position name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e job position name must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Employees:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Every employee must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"identificationNumber\"\u003c/code\u003e represents the employee population identification number. Can contain numbers and letters \u003ccode\u003eTEXT\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Identification number must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"name\"\u003c/code\u003e specifies the employee name. Employee name should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"surname\"\u003c/code\u003e Specifies the employee surname. Employee surname should not exceed 50 characters \u003ccode\u003eVARCHAR(50)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"gender\"\u003c/code\u003e Specifies gender information. Gender information should not exceed 15 characters \u003ccode\u003eVARCHAR(15)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"phoneNumber\"\u003c/code\u003e Specifies the working phone number. There are variable length \u003ccode\u003eTEXT\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. Must contain only numbers \u003ccode\u003eCHECK(\"phoneNumber\" GLOB '*[0-9]*')\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"email\"\u003c/code\u003e Specifies the employee e-mail address. It will contain special characters \u003ccode\u003eTEXT\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.  Must be unique \u003ccode\u003eUNIQUE\u003c/code\u003e. @ sign control \u003ccode\u003eCHECK(\"email\" LIKE '%@%'\u003c/code\u003e).\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"address\"\u003c/code\u003e represents address information. Cannot exceed 70 characters \u003ccode\u003eNVARCHAR(70)\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"jobPositionId\"\u003c/code\u003e indicates the job position number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'JobPositions' table is restricted.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"departmentId\"\u003c/code\u003e indicates the department number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Departments' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"shopId\"\u003c/code\u003e Shows the store number where it is located. for this reason \u003ccode\u003eINTEGER\u003c/code\u003e. this line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e. Constraint applied to the 'id' column in the 'Shops' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"startDate\"\u003c/code\u003e this job Date of start \u003ccode\u003eDATE\u003c/code\u003e. because it contains date. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Automatically gets the start date. \u003ccode\u003eDEFAULT CURRENT_DATE\u003c/code\u003e \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"salary\"\u003c/code\u003e Contains salary information. Salary must be numerical \u003ccode\u003eNUMERIC\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be greater than 0 \u003ccode\u003eCHECK(\"indemnityAmount\" \u003e= 0)\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"annualLeave\"\u003c/code\u003e Contains the number of permissions it has. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The automatically assigned value is 0 \u003ccode\u003eDEFAULT 0\u003c/code\u003e. Must be greater than 0 \u003ccode\u003eCHECK(\"annualLeave\" \u003e 0)\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"shopStatus\"\u003c/code\u003e Shows the employee's working status. Status should not exceed 10 characters \u003ccode\u003eVARCHAR(10)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Employeestatus should contain some options \u003ccode\u003eCHECK(\"workingStatus\" IN ('work','annual leave','terminated')\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Indemnity:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e Each compensation must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"employeeId\"\u003c/code\u003e Shows the employee's number for this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Employees' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"terminationDate\"\u003c/code\u003e date of compensation. Data type \u003ccode\u003eDATE\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Automatically gets that day's date \u003ccode\u003eDEFAULT CURRENT_DATE\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"workingDay\"\u003c/code\u003e total number of days worked by the employee. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be greater than 0\n\u003ccode\u003eCHECK(\"workingDay\" \u003e 0)\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"indemnityAmount\"\u003c/code\u003e Contains compensation fee information. Fee must be numerical \u003ccode\u003eNUMERIC\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Must be greater than 0 \u003ccode\u003eCHECK(\"indemnityAmount\" \u003e= 0)\u003c/code\u003e. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Annual_Leave:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each compensation must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"employeeId\"\u003c/code\u003e Shows the employee's number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Employees' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"annualLeaveUsed\"\u003c/code\u003e number of permissions used. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n**Orders:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each order must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"customerId\"\u003c/code\u003e customer ID who placed the order. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Customers' table is restricted.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"shopId\"\u003c/code\u003e Store number where the order was placed. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e.  The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Shops' table is restricted. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"orderDate\"\u003c/code\u003e Includes order date. For this reason \u003ccode\u003eDATE\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Automatically gets that day's date \u003ccode\u003eDEFAULT CURRENT_DATE\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"employeeId\"\u003c/code\u003e Shows the number of the Employee who created the order. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Employees' table is restricted. \u003c/li\u003e\n\u003c/ul\u003e\n\n**Order_Item:**\n\n\u003cul\u003e\n\u003cli\u003e \u003ccode\u003e\"id\"\u003c/code\u003e indicates the identification number. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. Each order-item must be unique \u003ccode\u003ePRIMARY KEY\u003c/code\u003e. Id should be auto incrementing \u003ccode\u003eAUTOINCREMENT\u003c/code\u003e.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"orderId\"\u003c/code\u003e order ID of the product.  For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e.  The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Orders' table is restricted.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"productId\"\u003c/code\u003e product ID in the orders.  For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty. \u003ccode\u003eNOT NULL\u003c/code\u003e. The \u003ccode\u003eFOREIGN KEY\u003c/code\u003e constraint applied to the 'id' column in the 'Product' table is restricted.\u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"quantity\"\u003c/code\u003e Information on how many pieces the product is. For this reason \u003ccode\u003eINTEGER\u003c/code\u003e. This line cannot be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Quantity must be greater than 0 \u003ccode\u003eCHECK(\"quantity\" \u003e 0)\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"price\"\u003c/code\u003e total price of the product. Fee must be numerical \u003ccode\u003eNUMERIC\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Fee - should not be \u003ccode\u003eCHECK(\"price\" \u003e 0)\u003c/code\u003e. \u003c/li\u003e\n\u003cli\u003e \u003ccode\u003e\"orderItemStatus\"\u003c/code\u003e Indicates the status of the product in the order. Status should not exceed 20 characters \u003ccode\u003eVARCHAR(20)\u003c/code\u003e. Should not be empty \u003ccode\u003eNOT NULL\u003c/code\u003e. Getting ready default value \u003ccode\u003eDEFAULT 'getting ready'\u003c/code\u003e. Product status should contain some options\n\u003ccode\u003eCHECK(\"orderItemStatus\" IN ('getting ready','delivered','refunded','cancelled').\u003c/code\u003e\u003c/li\u003e\n\u003c/ul\u003e\n\n### Relationships\n\nThe entity relationship diagram below describes the relationships between entities in my database.\n\n![ER Diagram](diagram.png)\n\n**Descriptions:**\n\u003cul\u003e\n\u003cli\u003eThere can be more than one store in a city, but the same store cannot be in many cities.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere can be more than one employee in a store, but an employee cannot work in more than one store at the same time.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eMultiple orders can be placed from one store, but two stores cannot be included in the same order.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere can be more than one employee in a department, but the same employee cannot be in two departments.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere may be more than one employee in a job position, but the same employee cannot be in two job positions.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThe employee has a compensation, the same compensation represents the one employee. (One to one relationship)\u003c/li\u003e\n\u003cli\u003eAn employee can take leave at different times, but the same leave cannot represent more than one employee.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eA customer can place more than one order, but the same order cannot represent two customers.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eAn employee can create multiple orders but one order cannot represent two employees.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere can be multiple items in one order, but the items cannot represent two identical orders.(one-to-many relationship)\n\u003c/li\u003e\n\u003cli\u003eA product can be in more than one order product table, but the order product id represents the same product only once. (one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere can be multiple items in one order and one item can be in multiple orders.(many-to-many relationship)\u003c/li\u003e\n\u003cli\u003eThere can be more than one product in a category, but a product cannot be in 2 categories.(one-to-many relationship)\u003c/li\u003e\n\u003cli\u003eA product has one brand, but the same brand may have multiple products.(one-to-many relationship)\u003c/li\u003e\n\u003c/ul\u003e\n\n## Optimizations\n\n**Indexing**\n\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003e\"customer_search\"\u003c/code\u003e To get faster results for user searches. \u003ccode\u003e\"name\",\"surname\",\"email\",\"address\"\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"product_search\"\u003c/code\u003e To speed up product searches.\u003ccode\u003e\"name\"\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"city_search\"\u003c/code\u003e To speed up city searches. \u003ccode\u003e\"name\"\u003c/code\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"shop_search\"\u003c/code\u003e To speed up store searches. \u003ccode\u003e\"name\"\u003c/code\u003e\u003c/li\u003e\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_search\"\u003c/code\u003e To speed up employee searches. \u003ccode\u003e\"name\",\"surname\",\"email\",\"address\"\u003c/code\u003e \u003c/li\u003e\n\u003c/ul\u003e\n\n**Views**\n\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_indemnity\"\u003c/code\u003e Shows employee compensation information.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_content\"\u003c/code\u003e It shows the detailed content of the order placed.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_totalprice\"\u003c/code\u003e It shows the total amount of the order placed.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"shop_city\"\u003c/code\u003e Shows store city connection information.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_annualleave\"\u003c/code\u003e Shows the permissions used by employees.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e \"employee_information\"\u003c/code\u003e Shows information about employees.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_information\"\u003c/code\u003e Shows the information of the order placed.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"product_details\"\u003c/code\u003e Shows information about products.\u003c/li\u003e\n\u003c/ul\u003e\n\n**Triggers**\n\n\u003cul\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_active_shop_control\"\u003c/code\u003e It checks the status of the shop from the shop information entered when adding employees.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_department_control\"\u003c/code\u003e It checks whether the department exists or not from the department information entered when adding an employee.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_jobPosition_control\"\u003c/code\u003e When adding an employee, it checks whether there is a job position from the job position information entered.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"employee_shop_control\"\u003c/code\u003eIt checks whether the shop exists from the shop information entered when adding an employee.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"annual_leave_employee_check\"\u003c/code\u003e Checks employee status and presence while employee is taking leave.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"annual_leave_check\"\u003c/code\u003e When taking leave, the employee checks whether he/she has enough leave and that the number of leaves is greater than 0.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"use_annual_leave\"\u003c/code\u003e After the employee takes leave, it is deducted from the leave count and its status is changed to on leave.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"indemnity_employee_controls\"\u003c/code\u003e When adding compensation, it is taken into account whether the employee is an employee or not.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"indemnity_employee_workstatus\"\u003c/code\u003e When compensation is added, the employee's situation changes.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"sales_shop_active_control\"\u003c/code\u003e The condition of the store is checked before the sale is made.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"sales_shop_control\"\u003c/code\u003e Before making a sale, it is checked whether the store exists or not.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"sales_employee_control\"\u003c/code\u003e The employee's status and existence are checked before the sale is made.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"sales_customer_control\"\u003c/code\u003e Before the sale is made, the customer's deletion status and existence are checked.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"product_control\"\u003c/code\u003e Before the sale is made, the sales status and existence of the product is checked.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"product_stock_control\"\u003c/code\u003e Stock control of the product is carried out before sales are made.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_cancellation_refund_procedures\"\u003c/code\u003e If the order is canceled, stock is added to the product.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_delivery_transactions\"\u003c/code\u003e The product stock decreases when the order product status is delivered.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"product_stock_end\"\u003c/code\u003e When the product stock count is 0, it changes its status to waiting for stock.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"adding_product_stock\"\u003c/code\u003e When stock is added to the product, its status is updated as sale.\u003c/li\u003e\n\u003cli\u003e\u003ccode\u003e\"order_state_update\"\u003c/code\u003e When the sale is completed without any problems, the product order status is updated as delivered.\u003c/li\u003e\n\u003c/ul\u003e\n\n## Limitations\n\n\u003cul\u003e\n\u003cli\u003einterstore transactions\u003c/li\u003e\n\u003cli\u003edetailed account transactions (E.g. Indemnity fee)\u003c/li\u003e\n\u003cli\u003eupdate checks, transactions with the data in the program are considered.\u003c/li\u003e\n\u003c/ul\u003e\n This database may not represent the detailed databases of large technology companies, but it was designed with inspiration from them.\n\n[![Hits](https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2Fmuhammedahmetsekerci%2FCS50-SQL-FINAL-PROJECT\u0026count_bg=%23A41034\u0026title_bg=%233D3D3D\u0026icon=\u0026icon_color=%23A41034\u0026title=hits\u0026edge_flat=false)](https://hits.seeyoufarm.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammedahmetsekerci%2Fcs50-sql-final-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuhammedahmetsekerci%2Fcs50-sql-final-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuhammedahmetsekerci%2Fcs50-sql-final-project/lists"}