I keep struggling with the best way to implement this. Let's say I have two objects, one is a user object the other is a note object. The Note object will hold notes for a patient and it will store who created the note and who it was last updated by. What is the better option:
Option A - Two objects, one with just the Note specific info and the other an extension of this object with the User objects for patient/author/updater:
public class Note {
private int noteId;
private int patientId;
private int authorId;
private int updatedById;
private String noteText;
private Date noteDate;
}
public class NoteExt extends Note {
private User patient;
private User author;
private User updater;
}
Option B - One Note object with User classes for patients, author, updater
public class Note {
private int noteId;
private User patient;
private User author;
private User updater;
private String noteText;
private Date noteDate;
}
Option A would bloat the application with a ton of files for the additional objects/db calls but would speed things up when getting lists of items. (Also is it correct to use extend in this case?)
Option B would mean not worrying about remembering which object to use when and only having one database function, but would repeat data if, for example, I were getting a list of all notes a user has created.
Is there an option C that's better??
I wouldn't base the DB on your data structures directly. How your arrange the data in Java and how you arrange it in the DB don't have to be the same and what makes sense for one may not make sense for the other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With