This is my first time programming and I’m struggling to understand what should be done with mysql commands and what should be done with Java (I’m programming the database with Java because it doesn’t need to be used over the web).
Say I have the following pipeline:
- get excel file from user. This excel file is identifiable under an ID number.
- extract info from the excel file.
- save the extracted info into the database. This info needs to remain identifiable by the aforementioned ID number.
- find the relevant ID number and get the saved extracted info
- create a text document with the info.
What I need help with is part 2.
Should I save the info under an instance of a java class?
Or should I immediately save all the info in the database in a table?
Right now I’m having a hard time even seeing the point of using a database since I’m so accustomed to seeing everything in classes. Please help!
Databases help with persistence. If you need to store information between 2 runs of your program, or you need to deal with more data than you can fit in memory at once (including virtual memory) then you need to persist data. If you don’t, then you don’t need a database.
MySQL in particular is a relational database, so you can often easily retrieve and manipulate portions of data based on relations — all the widgets that have more than 5 teeth for example.
If you’re used to classes, you’re used to classes having 1 to 1, 1 to many, and many to many relations with other classes. Databases can have the same. In a 1:1 relation, the columns are in the same table. In 1:many and many:many relations, you have relations between tables that can be joined.
See http://www.databasejournal.com/sqletc/article.php/1469521/Introduction-to-Relational-Databases.htm for an intro to relations in the context of databases.