Click here to Skip to main content
15,894,630 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Unrelated data layer question. Pin
dojohansen11-Feb-08 8:04
dojohansen11-Feb-08 8:04 
GeneralDAL Design Question Pin
Waleed Eissa24-Jan-08 2:42
Waleed Eissa24-Jan-08 2:42 
GeneralRe: DAL Design Question Pin
Mark Churchill25-Jan-08 4:24
Mark Churchill25-Jan-08 4:24 
GeneralRe: DAL Design Question Pin
led mike25-Jan-08 4:40
led mike25-Jan-08 4:40 
GeneralRe: DAL Design Question Pin
Mark Churchill25-Jan-08 4:55
Mark Churchill25-Jan-08 4:55 
GeneralRe: DAL Design Question Pin
Waleed Eissa27-Jan-08 3:16
Waleed Eissa27-Jan-08 3:16 
GeneralRe: DAL Design Question Pin
Mark Churchill27-Jan-08 5:19
Mark Churchill27-Jan-08 5:19 
GeneralRe: DAL Design Question Pin
Waleed Eissa1-Feb-08 18:58
Waleed Eissa1-Feb-08 18:58 
Mark Churchill wrote:
I wrote:
You can send multiple queries and get multiple responses in one round trip.



This was in reference to "...which I'm highly considering but a little concerned about how to execute multiple SQL statements..." - this isn't anything to worry about. A query isn't restricted to multiple statements - so you can send "select foo; select baz" in one ExecuteDataSet() and get back a DataSet containing multiple DataTables.


Well, I'm sorry, I probably should've explained it more clearly, actually what I meant here is that when you use stored procedures you can easily use many sql statements in the same procedure

for example:
begin transaction
insert into foo
update foo2 set ..
.. etc

This is very easy with stored procedures but I guess not so easy with ad-hoc sql statements, this is what I meant to say


Mark Churchill wrote:
A thread is basically a post that also has some extra information, like a title, a group it belongs in, etc. Say your database structure has a table, Product (Id, Description) and ServiceProduct(Id, CostPerHour) with ServiceProduct.Id being a foreign key to Product.Id. This defines that for every set of ServiceProduct data there is Product data, meaning ServiceProduct inherits Product, which is pretty analogous to how inheritance relationships work in code. This can be handy.

Using a ParentPostId field makes it difficult to pull a whole thread out the database. Given a parent post I would have to do an index scan to get the 2nd post, then again to get the 3rd, etc.

Say you have this setup:
Post (Id, Author, BodyText, TimePosted, ParentThreadId) and Thread (Id, Title, GroupId)
Thread.Id is a fk to Post.Id (inheritance)
Post.ParentThreadId is a fk to Thread.Id (reference)

This means that I can easily select threads in a group (Thread by GroupId), Posts in a Thread (Post by ParentThread).

If you are feeling uncomfortable with the inheritance relationship, then you could just have a Thread table that acts as a bit of a stub to group posts.

It might be worth having a look at how forums like phpbb handle their database structure (considering I'm coming up with this on the fly).


I like your idea about having a separate table for threads, I think this can speed things up as we can have less indexes on the same table, it might just be harder to maintain though as you have the data in two tables but I still like the idea.


Mark Churchill wrote:
I'm not comfortable with the LastUsedId. It seems incredibly unlikely you would approach the 4 billion odd posts that just an int would provide. SQL Server could handle that kind of indexing using the processor in my phone - you'd be out of disk before you ran out of primary keys - and if you need to partition, just move everything out by GroupId - having holes in your index isn't an issue.


Actually this wasn't meant for avoiding reaching the maximum limit for int as it's large enough (by the way the max is 2 not 4 billions as int is signed), it's intended for scalability to make it easier to move data to different databases (assuming a group has way too many posts and it's making the table too large so you move the data of this group into a separate database), so that you don't have to worry about the correct value of the seed for the identity field.

Thanks for all your help...


GeneralRe: DAL Design Question Pin
Ashfield30-Jan-08 4:24
Ashfield30-Jan-08 4:24 
QuestionBeta Testing? Develop Tech? Pin
Chrispie12323-Jan-08 19:00
Chrispie12323-Jan-08 19:00 
AnswerRe: Beta Testing? Develop Tech? Pin
Paul Conrad25-Jan-08 15:56
professionalPaul Conrad25-Jan-08 15:56 
GeneralVisual Studio 2005 collaboration Pin
Mike Nelson22-Jan-08 1:47
Mike Nelson22-Jan-08 1:47 
GeneralRe: Visual Studio 2005 collaboration Pin
led mike22-Jan-08 4:59
led mike22-Jan-08 4:59 
GeneralRe: Visual Studio 2005 collaboration Pin
Mike Nelson22-Jan-08 7:49
Mike Nelson22-Jan-08 7:49 
GeneralRe: Visual Studio 2005 collaboration Pin
led mike22-Jan-08 7:58
led mike22-Jan-08 7:58 
GeneralRe: Visual Studio 2005 collaboration Pin
Mike Nelson28-Jan-08 2:55
Mike Nelson28-Jan-08 2:55 
GeneralRe: Visual Studio 2005 collaboration Pin
led mike28-Jan-08 5:58
led mike28-Jan-08 5:58 
GeneralRe: Visual Studio 2005 collaboration Pin
Mike Nelson28-Jan-08 7:41
Mike Nelson28-Jan-08 7:41 
GeneralRe: Visual Studio 2005 collaboration Pin
led mike28-Jan-08 8:42
led mike28-Jan-08 8:42 
GeneralRe: Visual Studio 2005 collaboration Pin
Mike Nelson28-Jan-08 9:34
Mike Nelson28-Jan-08 9:34 
GeneralRe: Visual Studio 2005 collaboration Pin
led mike28-Jan-08 9:51
led mike28-Jan-08 9:51 
GeneralRe: Visual Studio 2005 collaboration Pin
Mike Nelson29-Jan-08 2:15
Mike Nelson29-Jan-08 2:15 
GeneralFree tool for UML Pin
mhmo21-Jan-08 2:42
mhmo21-Jan-08 2:42 
AnswerRe: Free tool for UML Pin
martinig29-Jan-08 6:46
martinig29-Jan-08 6:46 
GeneralRe: Free tool for UML Pin
Tristan Rhodes6-Feb-08 2:10
Tristan Rhodes6-Feb-08 2:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.