I have some programming experience only with databases but not OO programming, but I am trying to create a Library system. Loans and LoanLine has a 1.....* relationship. Thats fine. I know this unique fields and auto incremenets etc.
However, I'm trying to use a CSV file because its alien to me. Seems stupid as I know databases, yes probably is, but cant learn what I already know.
If I create a Loan file, how do I keep a unique Loan ID? or does Java have a wonderful API to help me do this CSV file stuff?
I will need two CSV files, Loan and LoanLine which will correspond to objects/classes.
e.g Loan file
The LoanLine file
1, 1, Rocky,07/07/12;
1, 2, Matrix,07/07/12;
Tom takes out 2 dvds.
How do I create my next Loan as I will need to know the Loan file already contains #1.
The only way is to read the last line of the Loan file and get value up to the comma, then add 1 to this number when I create a new Loan object?
Create Loan object.
Read Loan file, get last number, add 1 for the ID.
Now create LoanLine object.
I'm not expecting a thorough explanation, but if somebody could point me in the right direction. Read up on String buffer or IO file or read up on ****, that would be fantastic and much appreciated.
My problem in summary is doing the stuff that database usually do with indexes and primary and foreign keys.
How will I check that a Dvd is not out on Loan?
Search for "Matrix,07/07/12" and if it doesn't exist in LoanLine, its available. Loanline is linked to movies.
Does Java have a special API that makes all this reading and writing to CSV files easy? This is basically my question. I'm also still at the design stage of classes and the reading and writing from csv files to objects is confusing me.
I hope this makes sense to someone. Lol
Yeah, I have used the Ostermiller one pointed to on Campbell's link. It is good.
But CSV doesn't handle the logic of indexing and keys, and such. It is just a flat file format used for storage, akin to .txt but for columned data. If you want to do unique IDs then you will have to do that yourself.