web - Should server-side objects contain all database columns/relationships at creation time? -
i unexperienced computer science student , while making projects different courses few conceptual questions occurred.
say develop website similar imdb, music, scratch , want list artists on frontpage. database schema done relationship , attributes, , there table artists. should server-side artist-class contain table columns , relationships @ creation time not needed @ time? or should construct these objects minimal parameters (like id, name) , rest when needed (resulting in more individual sql statements) via helper-methods? know there maybe no definitive answer except 'it depends' or boils down personal preference, maybe there consensus. if name or link resources read on things grateful, didn't know search exactly. thanks.
ps: people wondering why don't ask these questions in cs course; held students/assistants had pass course , don't have experience themselves.
i not sure means answering assuming not exist in question. edit answer when clarification given.
or should construct these objects minimal parameters (like id, name) , rest when needed (resulting in more individual sql statements) via helper-methods?
actual answer starts here
it not boil down personal preference whether can or cannot find practical reason something. design patterns follow practicality instead of personal preferences. if there consensus can ask why.
if there 100 tables in database present , in web application can 2 of them don't see reason why should sit down , create 100 tables in web application's domain model. it's not logical.
there may cases when big application being created , 99% sure need model of , requires model bit more classes (say 5 instead of 2) ensuring our future work not hindered.
also there concern of data integerity. 2 tables depend on other table? table depend on them? if there dependency might need include tables also.
fyi such questions better suited on programmers stackexchange
Comments
Post a Comment