{"id":18867252,"url":"https://github.com/ahalic/transaction-schedule","last_synced_at":"2025-10-08T03:15:43.941Z","repository":{"id":120849586,"uuid":"527349305","full_name":"AHalic/transaction-schedule","owner":"AHalic","description":"Project for the class of introduction to Database I to find conflict on concurrent transaction scheduling ","archived":false,"fork":false,"pushed_at":"2022-08-13T23:18:50.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-30T22:32:03.802Z","etag":null,"topics":["database","plpgsql-scripts","sql"],"latest_commit_sha":null,"homepage":"","language":null,"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/AHalic.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":"2022-08-21T23:18:10.000Z","updated_at":"2022-08-24T14:07:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"c86c7ab5-9950-4be5-9192-f09a82ed8850","html_url":"https://github.com/AHalic/transaction-schedule","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHalic%2Ftransaction-schedule","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHalic%2Ftransaction-schedule/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHalic%2Ftransaction-schedule/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AHalic%2Ftransaction-schedule/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AHalic","download_url":"https://codeload.github.com/AHalic/transaction-schedule/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239816478,"owners_count":19701753,"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","plpgsql-scripts","sql"],"created_at":"2024-11-08T05:08:53.957Z","updated_at":"2025-10-08T03:15:38.892Z","avatar_url":"https://github.com/AHalic.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# :arrows_counterclockwise: Transaction Cycle Detection Given Schedule Table\n\nProject for the class of Database I to simulate the testing of serializability. In order to simulate, we create a schedule table representing the transactions and their operations. The Schedule table has the following format:\n- time: integer value, functioning as a timestamp of the operation done.\n- #t: integer value, representing the transaction.\n- op: R, W and C, representing Read, Write and Commit actions.\n- attr: character value, representing attribute that can be read, written or commited. \n\n## :computer: The Algorithm\n\nThe algorithm can be found on the file [find_cycle.sql](algorithm/find_cycle.sql). It consists in creating a Graph table that represents a directed graph. Each arc (x, y) is represented by the tuple (origin, destiny). Afterwards, the function *testeEquivalenciaPorConflito* is executed and saved as *resp*, with **1** representing *has cycle* and **0** representing *does not have cycle*.\n\n### Example \n\nGiven the following transactions:\n\n|  T1  |  T2  |  T3  |\n|------|------|------|\n| R(X) |      |      |\n| W(X) |      |      |\n|      | R(X) |      |\n|      |      | R(X) |\n| W(X) |      |      |\n|      |      | W(X) |\n|      | R(Y) |      |\n|      | W(Y) |      |\n|  C   |      |      |\n|      |  C   |      |\n|      |      |   C  |\n\nThe expected input values for the Schedule table is:\n| time | #t | op | attr |   \n|------|----|----|------|   \n| 1    | 1  | R  | X    |   \n| 2    | 1  | W  | X    |  \n| 3    | 2  | R  | X    |   \n| 4    | 3  | R  | X    |   \n| 5    | 1  | W  | X    |   \n| 6    | 3  | W  | X    |   \n| 7    | 2  | R  | Y    |   \n| 8    | 2  | W  | Y    |   \n| 9    | 1  | C  | -    |   \n| 10   | 2  | C  | -    |   \n| 11   | 3  | C  | -    | \n\nAfter running the find_cycle.sql, the following Graph table will be created:\n| origin | destiny |\n|--------|---------|\n|   1    |    2    |\n|   1    |    3    |\n|   2    |    3    |\n|   3    |    2    | \n\nRepresenting the following directed graph:\n\n\u003cimg src=\"images/graph.png\" alt=\"Graph image\" width=\"250\"/\u003e\n\nSince there's a cycle from 2 to 3, the *testeEquivalenciaPorConflito* returns 1.\n\n## :test_tube: Running the tests\n\nTo test the algorithm it's necessary to build and attaches the containers, then the tests can be ran. For that, you may use the following commands:\n\n```sh\ndocker-compose up\ndocker exec db /bin/bash -c 'sh src/test.sh'\ndocker-compose down\n```\n\nThe tests are located on the `test` directory, with the inputs and outputs files for each example. One of them is shown bellow.\n\n## Algorithm's requirements\n\nTo run the algorithm (`find_cycle.sql`), it is necessary to have a table named Schedule with the schema informed in the beginning. In case there isn't one, the file create_schedule.sql can be used. Before using the script again, the Schedule table must be cleaned and inputted its new values. The file clean_schedule.sql can be used for that purpose in case needed.\n\nDuring the algorithm, a Graph table will be created. With each execution of the algorithm, the table is dropped and created again, given the values in the Schedule table. \n\n\n## Github\n\n[Link](https://github.com/beamaia/transaction-schedule-sql) to access the full code.\n\n## Special thanks\n\nThe detect cycle portion of the code was based on this [link](https://stackoverflow.com/questions/26671612/prevent-and-or-detect-cycles-in-postgres).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahalic%2Ftransaction-schedule","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahalic%2Ftransaction-schedule","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahalic%2Ftransaction-schedule/lists"}