” CSC173程序 写作、database编程 写作、 辅导JavaCSC173: Project 4The Relational Data ModelIn this project you will gain experience with databases and relational algebra by implementingyour own database system. We will build on the presentation (and code) in thetextbook.Note: Your writeup for this project will probably be more extensive than previous projects.In addition to the usual instructions for building and running your project, please be sureto describe what your program is doing and what were seeing. Of course, that shouldalso be clear from the output of the program by itself.Part 11. Implement a database containing the relations (tables) shown in FOCS Figure 8.1and 8.2 (also seen in class). Use the method described in Section 8.2 in thesection Representing Relations and elaborated in Section 8.4 Primary StorageStructures for Relations. Use hashtables. Describe your implementation brieflybut clearly in your writeup.2. Implement the basic single-relation insert, delete, and lookup operations as functions.If you use the implementation described in the textbook, you will need separatefunctions for each relation (e.g., insert CSG). You should support leavingsome attributes unspecified for delete and lookup (denoted with * in the textbook,perhaps something else in your code). Describe your implementation briefly butclearly in your writeup.3. Use your insert method to Populate the tables with (at least) the data given in thefigures. Then demonstrate all three operations by performing the operations shownin Example 8.2 (p. 409). Be sure that your program explains itself when run (usinginformative printed messages).1Part 2For this part, use the database with all the tuples from Figures 8.1 and 8.2 (that is, beforeany deletions).1. Write a function to answer the query What grade did StudentName get in CourseName?as described in Section 8.6 Navigation Among Relations. The code foryour function MUST look like the pseudocode in Fig. 8.8. (I recommend using thepseudocode as comments in your code.) Demonstrate this functionality by askingthe user for the query parameters, performing the query, and printing the resultsinformatively (that is, a kind of REPL).2. Write a function to answer the query Where is StudentName at Time on Day?(assuming they are in Some course). Demonstrate this functionality also.Part 31. Implement the Relational Algebra operations as described in Section 8.8 and demonstratethis by doing the operations on the registrar database described in Examples8.12 (Selection), 8.13 (Projection), 8.14 (Join), and 8.15 (all three). Describeyour implementation briefly but clearly in your writeup. If you follow the implementation in the textbook, you will probably need adifferent function for each different set of arguments to the operator (e.g.,select CSG, join CSG SNAP). Only implement the ones that you need forthe examples listed above. You may also throw in any additional examplesthat you feel illustrate relevant aspects of your implementation. Note that some of the Relational Algebra operations create a relation with anew schema from that of their operands. (You should know which operationsdo this. . . ) But if tuples are implemented using structs, how do you createinstances of these new on-the-fly relations?The answer is that you should solve the problem yourself by hand so thatyou know the schemas needed by your examples. Then add appropriatestructure definitions to your program to allow you to do the examples. This isone of many Differences between what you need to do for this project and areal database framework.2Extra Credit (20% max total)1. Implement functions for saving your database to one or more files, and loadingfrom the same. Demonstrate this functionality in your program(s) and explain inyour writeup. Note: you can do all the other parts of the project even without thisfunctionality, so dont let it stop you or slow you down. [max 10% extra]2. The code you wrote for the registrar database is obviously specific to it. A truedatabase system, like SQLite or MySQL, allows you to represent any databaseschema. Generalize your code to represent arbitrary databases consisting of arbitraryrelations. Note that you do not need to understand SQL for this. What youneed to do is create generic representations of tuples and tables and then usethem to write code for some specific example.If you choose to do this, and are confident in your implementation, you may use itfor the required parts of the project. Explain what youve done in your writeup andwe will give you the Extra points if it all works. You may also choose to demonstratethis separately, for example with another program. Again, be clear in your writeupso that we can give you the points. [max 10% extra]3. Identify a subset of SQL that you can support with your implementation. You shouldfocus on the query parts of the language, not the data definition parts. Write asimple parser for that language, and use it to query (and perhaps also create) theregistrar database. Demonstrate this by also allowing the user to enter queriesand have your system parse and execute them and print the results. Explain whatyouve done and how it will be demonstrated by the program(s) in your writeup.[max 10% extra]Project SubmissionYour project submission MUST include the following:1. A README.txt file or README.pdf document describing:(a) Any collaborators (see below)(b) How to build your project(c) How to run your Projects program(s) to demonstrate that it/they meet therequirements2. All source code for your project. Eclipse projects must include the project settingsfrom the project folder (.project, .cproject, and .settings). Non-Eclipse3projects must include a Makefile or shell script that will build the program peryour instructions, or at least have those instructions in your README.txt.3. A completed copy of the submission form posted with the project description.Projects without this will receive a grade of 0. If you cannot complete and savea PDF form, submit a text file containing the questions and your (brief) answers.We must be able to cut-and-paste from your documentation in order to build and runyour code. The easier you make this for us, the better grade your will be. It is yourjob to make both the building and the running of programs easy and informative for yourusers.Programming PoliciesYou must write your programs using the C99 dialect of C. This means using the -std=c99option with gcc or clang. For more information, see Wikipedia.You must also use The options -Wall -Werror. These cause the compiler to reportall warnings, and to make any warnings into errors that prevent your program from compiling.You should be able to write code without warnings in this course.With these settings, your program should compile and run consistently on any platform.We will deal with any platform-specific discrepancies as they arise.If you submit an Eclipse project, it must have these settings associated with the project.Projects with that compile with warnings will be considered incomplete.Furthermore, your program should pass valgrind with no error messages. If you dontknow what this means or why it is A Good Thing, look at the C for Java Programmersdocument which has a short section about it. Programs that do not receive a clean reportfrom valgrind have problems that should be fixed whether or not they run properly. Ifyou are developing on Windows, you will need to look for alternative memory-checkingtools.Late PolicyLate projects will not Be accepted. Submit what you have by the deadline. If there areextenuating circumstances, submit what you have before the deadline and then explain4yourself via email.If you have a medical excuse (see the course syllabus), submit what you have andexplain yourself as soon as you are able.Collaboration PolicyYou will learn the most if you do the projects YOURSELF.That said, collaboration on projects is permitted, subject to the following requirements: Groups of no more than 3 students, all currently taking CSC173. You must be able to explain anything you or your group submit, IN PERSON ATANY TIME, at the instructors or TAs discretion. One member of the group should submit on the groups behalf and the grade willbe shared with other members of the group. Other group members should submita short comment naming the other collaborators. All members of a collaborative group will get the same grade on the project.Academic HonestyDo not copy code from other students or from the Internet.Avoid Github and StackOverflow completely for the duration of this course.There is code out there for all these projects. You know it. We know it.Posting homework and project solutions to public repositories on sites like GitHub is a violationof the Universitys Academic Honesty Policy, Section V.B.2 Giving UnauthorizedAid. Honestly, no Prospective employer wants to see your coursework. Make a greatproject outside of class and share that instead to show off your chops.5Frequently Asked QuestionsQ: In C, how can I make a hashtable that can hold any kind of tuple?A: How would you do it in Java? Think about it. . .Answer: Generics. And indeed java.util.Hashtable is a generic class.Now, does C have generics? Answer: no. So this is an example of thekind of thing added to Java as it evolved from C, in order to capture commonprogramming patterns more effectively. But if all we have is C, what can wedo?For some dynamic data structures, you can just manage generic objects oftype void* and use casts as needed (I STRONGLY suggest that you encapsulatethe casts in helper functions).The problem is that unlike a linked list, a hashtable needs to know somethingabout the objects it is managing. Why? Because it has to hash them,which means accessing some of their components. So you need to be ableto tell the generic hashtable code which hash function to use for each typeof struct it will be managing. There are ways (e.g., function pointer in tuple orhashtable), and they all amount to reinventing (in fact, pre-inventing) the ideaof true classes.You could just cut and paste the code for different flavors of hashtable. So theroutines use the right type of struct for arguments and they know what hashfunction to use. Is this ugly? Yes. Is it bad software engineering practice?Yes. Is it ok for this project? Yes. This is similar to the business about theschemas of tuples produced by JOIN operations, as described in the projectdescription Part 3.If you were ambitious you might observe that the cut-and-paste method ispurely mechanical, Other than writing the hash function itself. That is, youbasically go through and change all occurrences of the element type nameand thats really all you need to do. Given that, you could define a macro ormacros that expanded into the code. Something like:#define RELATION(ETYPE,HFUNC) …for element type ETYPE and name of hash function HFUNC. Using macrosis a bit of a power C Programmer technique. But it is how we did genericcode back in the day, and as you may know, C++ grew out of just this kind ofmacro-powered code.You could also implement tuples using something other than structs, as describedin one of the Extra Credit problems. There are many possibilities. . .如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。