json - Java Database Correct Approach -
i have built small javafx 2 scenes. user can input 3 fields (text) , upload documents object.
so thinking when user clicks save json object created , appended list of json objects. json objects written file.
this of thinking:
{ "objects": { "object1": { "field1": "foo" "field2": "foo" "field3": "foo" "folderwithfileslocation": "c:/programfiles/myapp/foobar/" }, "object2": { "field1": "foobar" "field2": "foobar" "field3": "foobar" "folderwithfileslocation": "c:/programfiles/myapp/barbar/" }, ....... .... .. }
these read objects on startup, user has access them, can edit them, add, delete, etc etc typical crud.
is correct approach ? there maximum 500-600 records. should add unique id (idk randomuuid()
)?
thanks
most database schemas add uuid primary key, it's important realise why - primary key allows specific document. if user updates or deletes specific document, you'll need way find record in database can apply action.
if 1 of other columns (possibly folder?) unique (and not nullable) serve pk without adding uuid. equally, if objects read list use index in list pk, makes assumptions ordering of list. if won't job you, adding pk idea, , uuid 1 way that.
personally, i'd expect worth adding uuid debugging alone. overheads tiny , makes big difference traceability.
Comments
Post a Comment