Starting from:
$35

$29

Programming Assignment 4: Transactions Solution




Overview




In this assignment you will write a program that allows a database user to enclose SQL statements into a transaction block. That is, you will implement the “all-or-nothing” property commonly seen in real-world database systems. This assignment assumes the metadata and data manipulations have been implemented in the frst three programming assignments.




System Design




You will decide how to guarantee the atomicity of transactions o In lectures: locking, timestamps, etc.

o As always, you are free (in fact, encouraged) to come up with your own design




In the design document, you should clearly explain how your program implements the atomicity property of transactions. The easiest way to do this is to declare lock variables shared between processes. For example, you can create an empty fle called “<table_name_lock” to indicate an existing process is accessing <table_name. In this case, we also assume the procedure of creating the empty fle is atomic: at any time, only one process is able to create/delete the lock fle (recall the P/V operations in your operating system class). As a result, after a transaction starts, the system will frst check the <table_name_lock fle before granting accesses to that specifc table <table_name. If there does exist such a lock fle, then the system will reject/suspend the access request. Otherwise, everything works as before (e.g., updating tuples), except that the change will not be persisted to the disk until a “commit” is encountered.










Implementation




The program should not use external database library/application.




Any programming language is acceptable, e.g., Python, Java, C/C++, Go o Just pick one(s) that you are most comfortable/profcient with

o But keep in mind we will test your code in Linux with OS-level utilities (e.g., fles)




So, probably not: C#, Object-C, JavaScript, Prolog… Functionalities:




SQL: Begin Transaction, Commit









CS457/657 Spring 2018 – Programming Assignment 4



Interface




A similar but simpler interface than Sqlite3




Same as homework #1: standard input, standard output.




This is very important, because in this assignment the program will be tested using two (2) interactive terminals (to emulate two concurrent processes/clients).



Testing




We will test your program on Ubuntu (version 14 or above)




If your program cannot compile on our testbed, we may ask you to demo your program




o Try not to use many exotic libraries… A full test script will be provided




We will NOT simply redirect the provided .sql fle as standard input to your program
Because there will be two clients/processes/terminals




Please, carefully read the comments in the given .sql fle, and understand what the expected output means
We will not to test your programs with any other scripts/commands It’s always good to consider more corners cases



Grading (100 points)




This assignment can be completed by a group of 1-3 students o All group members will receive the same score

Design document that clarifes the followings: (10 points)




At a very high level, how you implement the required atomicity property of transactions.
Be very specifc on how to compile and execute your code Source code (90 points)



Coding style, 10 points



Appropriate parenthesis locations, indention, etc.




Coding clarity, 10 points



Always write comments at the beginning of any fles Author, date, history, etc.




Always write comments at the beginning of any non-trivial class/ function




What this class/function does, high-level algorithm if needed




Write in-line comments for non-trivial blocks of code




Functionality, 70 points



Submission




CS457/657 Spring 2018 – Programming Assignment 4


WebCampus




Compress all your source code and documents into one package in this format:




o <your_netid_pa4




Each group member should submit his/her own copy of the package Late penalty: 10% per day (if you don’t use the 4-day grace period)






































































































































































CS457/657 Spring 2018 – Programming Assignment 4

More products