Solved

Database Best Practice (patterns)

Posted on 2004-04-16
8
166 Views
Last Modified: 2010-04-24
Well, this is more of a best practice question then actually how to do something.

I am developing an app (practice) where it is talking to a database.  Everything is working fine.  

The database consist of 3 tables, personnel, course_xref, and course.  As you can guess, the course_xref table consists of personnel with many courses.

I am creating a class within VB that would concidered a personnel record, with many of the same fields within the personnel table.  Now....

Should I create a course class and have an array of courses within my Employee class OR should I dynamically create the list of classes when it is needed.  (If I am displaying information regarding an Employee and I want to see all courses this person has taken, do I want to display it as text or store each one into an array of objects and display each one that way. )

Thanks for your help.
0
Comment
Question by:lfabbric
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 64 total points
ID: 10849016
a courses class (the collection of class objects that represent the classes taken by a given person is the best appraoch).  The courses class would then have a FACTORY method, to add a new class to the person - so that classes could NOT be created as a stand-alone entity, but by being associated with a specific person.  So the Course class would NOT have a PUBLIC constructor, and thus could not be independently created as a New Course

Dim course as New course

would fail to compile,

where

Dim course as Course = course.Add(PersonID)  

would create a new course object, and assign it to the person whose Id you pass in the Add mthod call.

AW
0
 
LVL 2

Assisted Solution

by:navneet77
navneet77 earned 62 total points
ID: 10875958
What if he needs to get the list of available courses. Then it wont be associated with any person. I think lfabbric needs to analyse what he wants to achieve and what are his requirements before making the right decision.
0
 
LVL 27

Expert Comment

by:planocz
ID: 10877552
Hi lfabbric,

Here is where I found a good example for Databases in VB.Net

.....http://msdn.microsoft.com/vbasic/downloads/samples/101samples.aspx
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 1

Author Comment

by:lfabbric
ID: 10878561
I have to browse courses by both employee's and courses.  (I am just playing around with a production application and converting it into ASP.NET/VB.NEt)

The application allows people to browse courses by course or by person.  Or make reports based on courses and show all people who have taken courses.  I think ... I need to be looking into the Factory Pattern.  It has a few examples as to how to handle this kind of things.

Does anyone have any comments on this.
0
 
LVL 27

Assisted Solution

by:planocz
planocz earned 62 total points
ID: 10878641
Hi lfabbric,

Here is another link for ASP.net examples....

http://www.asp.net/Default.aspx?tabindex=9&tabid=47
0
 
LVL 1

Assisted Solution

by:M_o_n_t_y
M_o_n_t_y earned 62 total points
ID: 10882257
I would create a collection class of courses that has all the regular collection methods you need plus a method like LoadForEmployee() that takes an employee ID as an argument. This way you can use the collection in a 'stand-alone' way when you only care about the courses and not employees, and the employee class can also expose the collection as a read-only property.

In regards to whether or not to load up all the course objects in the employee object or to wait until they are actually needed, ask yourself these two questions:
1) Do I often have many employee objects loaded up at concurrently?
2) When I load up an employee object, am I usually going to access it's collection of Course objects?

If number one is yes and/or number two is no, you'll probably want to employ a JIT technique where when the course collection is requested from the employee object, it first checks to see if it exists, and if it doesn't it creates it and then returns it.

Hope that helps...
             
                                 -Monty
0

Featured Post

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question