Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0
This is the forum to discuss the Wrox book ASP.NET 2.0 Website Programming: Problem - Design - Solution by Marco Bellinaso; ISBN: 9780764584640
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2008, 06:27 AM
Registered User
 
Join Date: Dec 2008
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default Help with 3-layer architecture

I am following the book to try to change an old .Net 1.1 application to use ObjectDataSource and 3-layered architecture, and have reached a point where I don't understand and can't find information about where the heck I do things that I know how to do in codefiles in 2-layer architecture...

To form a complete record for the UI, I need to join two tables together. It cannot be done in a query - the tables are in separate databases and canot be accessed in a single query.

The pseudo-code woud be:

fill DataTable1 from database A
fill DataTable2 from database B

[To Do]
create DataTable 3
create DataRelation between DataTable 1 and DataTable 2

add joined records to DataTable 3

bind DataTable 3 to the DataGrid
[/To Do]

There are 12 different data displays in the UI, and the 12 different .Net 1.1 codefiles use essentially the same code shown above. It seems to me that an ObjectDataSource and layered architecture would make life ever so much more pleasant -- if I can find out how to create that final DataTable to bind to the controls.

I really don't have a clue at the moment, and could use help.

Tinker
  #2 (permalink)  
Old December 15th, 2008, 10:27 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
Originally Posted by T. R. Tinker View Post
I am following the book to try to change an old .Net 1.1 application to use ObjectDataSource and 3-layered architecture, and have reached a point where I don't understand and can't find information about where the heck I do things that I know how to do in codefiles in 2-layer architecture...

To form a complete record for the UI, I need to join two tables together. It cannot be done in a query - the tables are in separate databases and canot be accessed in a single query.

The pseudo-code woud be:

fill DataTable1 from database A
fill DataTable2 from database B

[To Do]
create DataTable 3
create DataRelation between DataTable 1 and DataTable 2

add joined records to DataTable 3

bind DataTable 3 to the DataGrid
[/To Do]

There are 12 different data displays in the UI, and the 12 different .Net 1.1 codefiles use essentially the same code shown above. It seems to me that an ObjectDataSource and layered architecture would make life ever so much more pleasant -- if I can find out how to create that final DataTable to bind to the controls.

I really don't have a clue at the moment, and could use help.

Tinker
Hi Tinker,

It will really depend on the type of relationship that you have between the tables (i.e. parent/child etc). in a 3 layered architecture, you'd have a domain object that contained theses relationships. the child collection would be lazy loaded on demand (even if coming from a seperate database!!) and likewise, a child member would know how to get it's parent. If you look at the articles BLL object in the code download above (http://www.wrox.com/WileyCDA/WroxTit...-DOWNLOAD.html), then you'll see all of this in play via article->category and article->comments definitions.

In order for you to implement the functionality across different databases, you'll need to get a handle on using the provider model and dependency injection as this will be the technique that you'll use to map the underlaying DAL data providers to the upper BLL domain objects.

I'll see if i can provide a good example of this that you can try 'at home' by implementing a parent/child domain obect (with a category parenting the parent)...

i'll get back to you, unless of course, you get my drift from the message content above.
__________________
jimi

http://www.originaltalent.com
  #3 (permalink)  
Old December 15th, 2008, 10:50 AM
Registered User
 
Join Date: Dec 2008
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thank you, jimi, I will follow the link you recommended. I thought I'd read every online article available in the past week, but this is a link that's new to me, so I was wrong.

If you can post a sample, I'd be ever so grateful. Please understand that I do NOT understand the term "domain object" you rasied, but am busily searching for its meaning even as I post this.

FYI: The tables have a parent-child relationship; and the relationship is created two different ways: eleven of the server controls use DataTable A as the parent; one uses DataTable B as the parent. But I'm sure if I see how and where I'm supposed to do this in a layered architecture - just once - I'll get the concept.

If the article gives me a "Eureka!" moment, I'll let you know. Until then, any additional help would be appreciated.

- Tinker
  #4 (permalink)  
Old December 15th, 2008, 04:19 PM
Registered User
 
Join Date: Dec 2008
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

jimi - I've had The Beer House for a while, but I went back through it to see if I missed something; and if the answer is in there, I'm still missing it...

Let me try to explain this again - I work alone so I don't get to talk to other programmers hardly ever and I am losing the skills for explaining things technically well.

If all of the data were in a single database, I would have to use a join query against several tables to complete one record. The data is displayed without category/items: it is displayed as a grid of all the individual records.

The data is room schedules. There are 398 rooms. The events scheduled in all of the 398 rooms is in Database A, the "translations" of some data stored as codes (in Database A) is in Database B.

These are inseparable data segments; no table from either databaser has enough information to form a complete record by iteself. I need to read everything in Database A, then find the "translations" for the codes in those records by reading them from Database B.

For example, Database A will tell me that event "183" is scheduled in room "16" from 7AM until 9AM sponsored by person "x". I need to read Database B to find out that event "183" is named "Special Video Conference", that room "16" is "Teleconference Room C" and that person "x" is "Mary Jones".

In the end I come up with one record, not a category/sub-category (parent/child?) dataset.

Does that help understand where I lost it in layered architecture? Right now, I can retrieve the information I need from Database A into a DataSet, and I can also retrieve the information I need from Database B into the DataSet. Now I have to relate the tables and join them together to make my final DataTable.

I don't know where to do this. I probably don't know how to do it in the new architecture either, but if I can learn where, I'll figure out how...

If we are talking about the same thing and I am not understanding your post, please let me know.

Thank you, jimi; appreciate the suggestion.

- Tinker
  #5 (permalink)  
Old December 16th, 2008, 10:16 AM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
Originally Posted by T. R. Tinker View Post
The data is room schedules. There are 398 rooms. The events scheduled in all of the 398 rooms is in Database A, the "translations" of some data stored as codes (in Database A) is in Database B.

These are inseparable data segments; no table from either databaser has enough information to form a complete record by iteself. I need to read everything in Database A, then find the "translations" for the codes in those records by reading them from Database B.

For example, Database A will tell me that event "183" is scheduled in room "16" from 7AM until 9AM sponsored by person "x". I need to read Database B to find out that event "183" is named "Special Video Conference", that room "16" is "Teleconference Room C" and that person "x" is "Mary Jones".

In the end I come up with one record, not a category/sub-category (parent/child?) dataset.

- Tinker
Tinker,

Ok, your data is basically using tables from the 2nd database as lookups. this is still a feasible scenario to implement under the architectural design that you are keen to adopt.

i've quickly put together a little scenario based on the following assumptions:

1. database A contains a table called (for this test) Schedule
2. database B contains 3 lookup tables called EventType, Resource, Person

i know your own implementation will vary, but this may at least give food for thought (rather than using your exact datastructure which you may know too well, so will learn less from)

you can grab my example from here:

http://www.originaltalent.com/downloads/Tinker.zip

good luck...

[edit] if at all possible, i would attempt to 'champion' a migration away from access and instead, rationalise the data and put it into sqlserver (even if still in seperate databases if that's what's required). it's just that you're going to lose out a lot on scalability if you carry on down the same road. I know that from bitter experience 5-6 yrs ago when an internal cost allocations app created for a bank required a similar change. the 'inhouse guru' argued that we couldn't upgrade the database for a variety of mainly political reasons. to cut a long story short, this bank got incorporated into a larger structure and when they tried to shoehorn their data into the existing database, everything ground to a halt. luckily, not being satisfied with the previous guru's recommendations, my team had migrated the data out to sqlserver some 6 months prior to this business change and were able to prove that the migration side-effects had been mitigated thro intensive testing over this period (to be honest, there wasn't a whole lot of issues to deal with). So, i'd urge you to at least think about how you could engage in a meaningful discussion to effect an upgrade path to sqlserver (or mysql etc).
__________________
jimi

http://www.originaltalent.com

Last edited by jimibt; December 16th, 2008 at 01:34 PM.. Reason: edit section needed to stand out more
The Following User Says Thank You to jimibt For This Useful Post:
T. R. Tinker (December 16th, 2008)
  #6 (permalink)  
Old December 16th, 2008, 01:57 PM
Registered User
 
Join Date: Dec 2008
Posts: 6
Thanks: 3
Thanked 0 Times in 0 Posts
Default

For pity's sake, jimi! This is far beyond what I'd hoped-for. If I can't learn the technique from this brilliant response, I need to burn my keyboard and deny I've so much as glanced towards a computer. Thank you.

No argument about the database. When I first protoyped this, my assumption was that she'd use DTS to import the Access databases into SQL Server 2000 on an automated schedule, but it hasn't worked out that way. Now I have the all of my DTS scripts translated and tested for SQL 2005 Integration Services, and am still waiting...

Hope your end-of-year holidays are safe and happy, jimi. This was an unexpected present and I am truely grateful for your time and effort.

- Tinker
  #7 (permalink)  
Old December 16th, 2008, 04:26 PM
Friend of Wrox
 
Join Date: Mar 2007
Location: Creetown, UK
Posts: 488
Thanks: 2
Thanked 11 Times in 10 Posts
Default

Quote:
Originally Posted by T. R. Tinker View Post
For pity's sake, jimi! This is far beyond what I'd hoped-for.
- Tinker
Tinker,

To be honest, i just fancied the challenge to prove that the BeerHouse architecture could cope with this type of demand (which of course, i knew it could). At the end of the day, all i did was create the 'master' structure inside DatabaseB and then run the flixon site builder against it. i then copied the schedule table to DatabaseA and renamed the schedule table in DatabaseB. All that was left to do, was to create a new connectionstring as well as adding the additional overrides to the web.config as shown below:

Code:
    <main providerType="TNK.Scheduler.DAL.SqlClient.Main.DataProvider"  connectionStringName="DatabaseA" />
    <lookup providerType="TNK.Scheduler.DAL.SqlClient.Lookup.DataProvider" connectionStringName="DatabaseB" />
That was all there was to it. If you plan on using two or more databases in this fashion, that would be my recommended approach to it (i.e. set everything up in a single database and map all the foreign keys where required, then run the site generator. finally, break out the tables that you require to the other databases and then just add the appropriate connectionstrings and provider overrides.

let me know how you get on if you decide to work in this fashion - and you have a happy xmas and great new year as well ;)
__________________
jimi

http://www.originaltalent.com
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handle error from database layer to applican layer khatu_jec ASP.NET 2.0 Basics 1 November 9th, 2008 03:51 PM
architecture MunishBhatia ASP.NET 2.0 Professional 3 October 6th, 2007 05:24 AM
Application Architecture balesh.mind ASP.NET 2.0 Professional 3 July 26th, 2007 11:26 AM
3 tire architecture rajdotnet ASP.NET 1.x and 2.0 Application Design 1 October 19th, 2006 01:54 PM
Grid Architecture GibiJ SQL Server 2000 3 January 5th, 2006 03:06 AM



All times are GMT -4. The time now is 08:24 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.