I’m trying to develop a small plugin-based training calculator as a home project (designed with weight training in mind) using Java.
The application core provides certain services that a plugin may interface with. One of these is the so-called “data service”, that lets the plugin store data and retrieve them. Now, I feel that the way my objects are built doesn’t mesh well with a relational DB, or even object-relational DBs. But I would like to be able to do some searching and querying, which may not be feasible or easy to do if my objects are stored as binaries.
The problem is that I want to store a single entry (LogEntry object), which is an object consisting of one or more object components, which again consists of one or more object components.
My objects look like this (pseudocode):
// This is the plugin itself
class Log
{
member PersonalStats;
member LogBook; // ideally, this would be a table with the log entries
... // methods
}
/* ================= */
// part of Log class
class PersonalStats
{
member Date birthdate;
... // etc., all the personal stuff
... // methods
}
// part of Log class
class LogBook
{
member List<LogEntry> entries;
... // methods
}
/* ================= */
// an object of this class should represent one dataset in LogBook
class LogEntry
{
member List<ExerciseDetail> exercises;
member String comments;
member Date date;
... // methods
}
/* ================= */
class ExerciseDetail
{
member Exercise exercise;
member List<SetSchema> warmUps;
member SetSchema workSet;
... // methods
}
class Exercise
{
member String name;
... // methods
}
class SetSchema
{
member int sets;
member int reps;
member double weight;
... // methods
}
My question is: In order for the core application to be able to provide database support, what kind of DBMS would be appropriate for this kind of data schema? I would like it to be non-language-specific.
I’m not sure, if databases are the way to go, though. So, if you have any suggestions, please feel free to share them.
Yours is a good case for Related Entities. Some of the obvious relations are
Log --> One To One --> PersonalStats, LogBookLogBook --> One To Many --> LogEntryLogEntry--> One To One --> ExerciseDetailExerciseDetail --> One To One --> ExerciseExerciseDetail --> One To Many -->SetSchemayou can neatly map these Entity Relations to database tables and as suggested by Thom, use ANy OR Mapping tools like Hibernate . Use spring as a integration layer.