Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Database Best Practice (patterns)

Posted on 2004-04-16
8
Medium Priority
?
168 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 256 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 248 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 248 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 248 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

670 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