Discussion Locked

which way?

0 helpful
1 reply
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am design ing a OO structure for a corp Intranet with ASP/VBscript (no com or .net as yet)

scenario

i have two over simplified db tables listed below.

employees
---------
id
first_name
last_name

documents
---------
id
title
body
author_id (ie. emloyee ID)

When setting up my classes i have seen the usual way to do this is to provide methods that extract the details i require from the table and returns as recordset (often with table joins). This works fine but invloves so many changes in the design.

On the other hand I have been loading each document record into the document object properties and accessing them through that. This allows me to set the author_id as an employee object and return the first_name and last_name without having to link the tables in my stored proc.

I haven't seen this method before, is it regarded as to db intensive (although it separates the classes so well)? I obviously have many classes wanting to access the employee class and changes only have to made in one place.

Thoughts would be appreciated and more details at http://onestopsurf.com/builder.htm

1 reply

by Member 23161263

I'm not sure that I get your question right..

option 1:
The employee class contains a reference to the collecion of documents

option 2:
The document class contains a reference to a the employee class.

Such design IMHO depends on the aim of your application.
If the application is about "documents" it may be wiser to model as option 2.

If the application is about "employees", then option 1..
But keep in mind that in this case the relationship is one to many. Depending on the the average number of documents per employee, it may be wise to delay the loading of the collection of documents..

This discussion is closed to new replies.