Best practices for retrieving lookup values for foreign keys


Author
Message
Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Hi,

I'm trying to figure out the best way to handle descriptive lookup values associated with foreign keys on a business object.  I've read some of the past discussions (e.g. http://forum.strataframe.net/Topic12507-7-1.aspx?Highlight=RowPopulating+browse) and it is looking like custom field properties may be the way to go in many cases. 

For example, I have a staffBO for all teachers in a school district.  Each record has an FK_School foreign key pointing to the teacher's school.  On my StaffMaintenanceForm Browse Dialog I want the school title (not FK) to show in the results column.  So I added a cSchoolTitle custom field to StaffBO as shown below (using a call to SchoolBO.FillByPrimaryKey()). 

This works fine, but I'm concerned about the speed and network demands of repeatedly doing a FillByPrimaryKey() each time a staff record is retrieved.  I'm also trying to better understand what is going on behind the scenes, so please bear with me...

Does the FillByPrimaryKey() actually query the backend School table for each staff record?... or is some fancy buffering going on?  I know doing this for a few hundred staff records may be trivial, but other tables with similar lookup requirements may have 10,000 records.

Is there a better way to just pull the entire School table into a local BO one time (using FillAll()) and look up the school titles there?  Would this alternate approach be preferable for small lookup tables?

I've considered using a multi-table BO (based on SQL views that have joins to needed lookup tables) but was stymied by how to make these updatable.

Thanks in advance,

Larry

Public ReadOnly Property [CSCHOOLTITLE]() As System.String

Get

Dim schoolbo As New SchoolBO

schoolbo.FillByPrimaryKey(Me.FK_SCHOOL)

If schoolbo.Count = 1 Then

Return schoolbo.CTITLE

Else

Return String.Empty

End If

schoolbo.Dispose()

End Get

End Property


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Larry Tucker - 16 Years Ago
Peter Denton - 16 Years Ago
Larry Tucker - 16 Years Ago
Peter Denton - 16 Years Ago
Larry Tucker - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Larry Tucker - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Larry Tucker - 16 Years Ago
Edhy Rijo - 16 Years Ago
Trent L. Taylor - 16 Years Ago
                         Larry, Here you can find the shared method Trent is talking about:...
Edhy Rijo - 16 Years Ago
                             Thanks, Edhy ;)
Trent L. Taylor - 16 Years Ago
                                 Trent, Thanks for the explanation and Edhy, thanks for the reference....
Larry Tucker - 16 Years Ago
Larry Tucker - 16 Years Ago
Larry Tucker - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Larry Tucker - 16 Years Ago
Trent L. Taylor - 16 Years Ago
Larry Tucker - 16 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search