{"id":22495212,"url":"https://github.com/osbm/ain3003-hw2","last_synced_at":"2025-03-27T21:16:06.750Z","repository":{"id":208713380,"uuid":"722219529","full_name":"osbm/ain3003-hw2","owner":"osbm","description":null,"archived":false,"fork":false,"pushed_at":"2023-12-11T16:43:15.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-01T23:38:31.850Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":false,"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/osbm.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":"2023-11-22T17:33:21.000Z","updated_at":"2023-11-22T21:05:39.000Z","dependencies_parsed_at":"2023-11-22T23:22:25.503Z","dependency_job_id":"de018f4b-e3e6-46c5-ba5a-81eb6de55411","html_url":"https://github.com/osbm/ain3003-hw2","commit_stats":null,"previous_names":["osbm/ain3003-hw2"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osbm%2Fain3003-hw2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osbm%2Fain3003-hw2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osbm%2Fain3003-hw2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/osbm%2Fain3003-hw2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/osbm","download_url":"https://codeload.github.com/osbm/ain3003-hw2/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245924507,"owners_count":20694730,"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":[],"created_at":"2024-12-06T19:26:24.679Z","updated_at":"2025-03-27T21:16:06.691Z","avatar_url":"https://github.com/osbm.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AIN3003 - DATABASE SYSTEMS AND CLOUD COMPUTING - Homework 2\n\n## Running the code\n\n### Prerequisites\n\n- Python\n- MySQL\n\nAnd install the required packages using the following command:\n\n```bash\npip install -r requirements.txt\n```\n\n### Running the code\n\n# Task 1\n\nTask1 creates the database and tables in MySQL.\n\n```bash\npython task1.py\n```\n\n# Task 2\n\nTask2 inserts fake data into the tables in MySQL.\n\n```bash\npython task2.py\n```\n\nOutput:\n\n```\nDoctor table filled with 200 rows of fake data.\nPatient table filled with 500 rows of fake data.\nPatientdiagnosis table filled with 1000 rows of fake data.\nBill table filled with 1000 rows of fake data.\nStaff table filled with 50 rows of fake data.\n```\n\n# Task 3\n\nTask3 prints the doctor names and all of their patients.\n\n```bash\npython task3.py\n```\n\nOutput:\n\n```\n|   Doctor name    |   Doctor fname   |   Patient name   |   Patient fname  |\n| ---------------- | ---------------- | ---------------- | ---------------- |\n| Tansev           | Akça             | Akif             | Aslan            |\n| Fatigül          | Yüksel           | Tayaydın         | Şener            |\n| Fatigül          | Yüksel           | Şali             | Akgündüz         |\n| Fatigül          | Yüksel           | Hürdoğan         | Çamurcuoğlu      |\n| Fatigül          | Yüksel           | Türkalp          | Çamurcuoğlu      |\n| Fatigül          | Yüksel           | Tunahan          | Eraslan          |\n| Lezize           | Zorlu            | Fenni            | Ergül            |\n| Lezize           | Zorlu            | Ruhide           | Korutürk         |\n| Korkmazalp       | Hayrioğlu        | Arıpınar         | Bilgin           |\n```\n\n# Task 4\n\nTask4 prints the patient’s name, doctor name the total debt for each patient where they patient fee is over 100.\n\n```bash\npython task4.py\n```\n\nOutput:\n\n```\n|   Patient name   |   Patient fname  |   Doctor name    |   Doctor fname   | Total debt       |\n| ---------------- | ---------------- | ---------------- | ---------------- | ---------------- |\n| Nazende          | Korutürk         | Döner            | Ülker            | 18507            |\n| Çamok            | Akçay            | Berran           | Durmuş           | 9889             |\n| Ağakişi          | Durmuş           | Erinçer          | Manço            | 7121             |\n| Gülüs            | Ertaş            | Abdiş            | Fırat            | 14316            |\n| Yasemen          | Yıldırım         | Buhari           | Demir            | 8136             |\n| Ergün            | Durdu            | Berran           | Durmuş           | 27434            |\n| İlgi             | Zengin           | Dilara           | Bilir            | 19385            |\n| Berksay          | Bilge            | Anargül          | Ergül            | 12681            |\n```\n\n\n## Description\n\n\nDatabase is consistent of 5 tables\n\ntable Doctor\n- dr_code (primary key)\n- Name\n- FName\n- Gender\n- Address\n- designation\n\ntable Patient\n- pat_id (primary key)\n- Name\n- FName\n- Gender\n- Address\n- TelNo\n- dr_code (foreign key to Doctor table)\n\ntable Patientdiagnosis\n- DiagNo (primary key)\n- DiagDetails\n- DiagDate\n- Remark\n- Other\n- pat_id (foreign key to Patient table)\n\ntable Bill\n- BillNo (primary key)\n- PatName\n- DrName\n- Datetime\n- Amount\n- pat_id (foreign key to Patient table)\n\ntable Staff\n- staff_id (primary key)\n- Name\n- Dept\n- Gender\n- Address\n- TelNo\n- dr_code (foreign key to Doctor table)\n\n\nThe Above database is for a Hospital Management. The tables provide the doctor, staffs details and patient details including doctor's appointments and the billing system.\nIn the schema, the primary key of each relation is underlined, and the domain of each field is listed before the field name.\n\nThe Database consists of 5 tables; patient, doctor, staff, diagnosis and bill.\n- The 'patient' table consists of the basic data about the patient.\n- 'doctor' consists of the information about doctor.\n- The table 'staff' consists of the information regarding the employees.\n- 'diagnosis' consists of data about the patient's health analysis.\n- And finally, 'bill' table has the fee for the patient.\n\nThe billing system is integrated within a single database.\n\n\n## Tasks\n\n### Task 1\n\nWrite the DDL statements required to create the tables, including appropriate primary and foreign key integrity constraints. Implement the task in python:\n\n```python\nfrom mysql import connector\nmy_connection = connector.connect(\n host=\"localhost\",\n user=\"root\",\n password=\"Secret_123\",\n database=\"banking\"\n)\nmy_cursor = my_connection.cursor()\n\"\"\"\ncreate tables\n\"\"\"\nmy_cursor.execute(\"\"\"\ninsert a ddl statement\n) engine=innodb\n\"\"\")\n```\n\n### Task 2\n\nWrite the DML statements to insert sample data to every table. Implement the task in python.\n\n### Task 3\n\nWrite the SQL statement to find the Doctor names and all of their patients.\n\n### Task 4\n\nWrite the SQL statement that will return the patient’s name, doctor name the total debt for each patient where they patient fee is over 100. The total order value for a Patient debt is the sum of all the bills related to the patient. Implement the task in Python.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosbm%2Fain3003-hw2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fosbm%2Fain3003-hw2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fosbm%2Fain3003-hw2/lists"}