Click here to Skip to main content
15,911,646 members
Home / Discussions / Database
   

Database

 
QuestionSQL server nested tables or what? Pin
iskaza21-Sep-06 13:14
iskaza21-Sep-06 13:14 
AnswerRe: SQL server nested tables or what? Pin
Rob Graham21-Sep-06 14:04
Rob Graham21-Sep-06 14:04 
GeneralRe: SQL server nested tables or what? Pin
iskaza21-Sep-06 14:22
iskaza21-Sep-06 14:22 
GeneralRe: SQL server nested tables or what? [modified] Pin
Rob Graham21-Sep-06 14:43
Rob Graham21-Sep-06 14:43 
QuestionOne more question Pin
iskaza21-Sep-06 15:12
iskaza21-Sep-06 15:12 
AnswerRe: One more question Pin
Rob Graham21-Sep-06 17:36
Rob Graham21-Sep-06 17:36 
QuestionRe: One more question Pin
iskaza22-Sep-06 3:00
iskaza22-Sep-06 3:00 
GeneralDesign question - returning varying results Pin
Judah Gabriel Himango21-Sep-06 5:47
sponsorJudah Gabriel Himango21-Sep-06 5:47 
Hi guys

I've got a design question regarding how something should be modeled in SQL. I have an object hierarchy like this:

class Foo
   - string
   - bool
   - int
   - Guid

class FooInheritor : Foo
   - double
   - int
   - int

class AnotherFooInheritor : Foo
   - float
   - string


And so on, with another 15 or so classes deriving from Foo.

In my SQL database, I have a Foo table that stores all Foo types (including inheritors), then another FooInheritorTable that stores FooInheritor-specific data, a AnotherFooInheritor table that stores AnotherFooInheritor-specific data, and so on.

My question is:
when doing SQL queries, what is an acceptable way to query for a Foo instance? If I do SELECT * FROM FooTable WHERE @ID = someID, that will give me all Foo-specific data, but if the Foo being returned is actually a FooInheritor, what then? I would need to do another query on the FooInheritorTable to get the FooInheritor-specific data. And if the Foo returned is actually AnotherFooInheritor, then I need to do another query on the AnotherFooInheritorTable, and so on.

Should I:
- not model the tables after the real objects?
- create a view that returns all possible data for all 15 or so tables?
- query the FooTable, then when I get the results back, do another query on the table specific for that type?

I'd love to hear any suggestions. Thanks for taking the time to read this long post.


Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Dumbest. Movie. Title. Evaaar.
The apostle Paul, modernly speaking: Epistles of Paul

Judah Himango


GeneralRe: Design question - returning varying results Pin
Eric Dahlvang21-Sep-06 6:42
Eric Dahlvang21-Sep-06 6:42 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango21-Sep-06 8:35
sponsorJudah Gabriel Himango21-Sep-06 8:35 
GeneralRe: Design question - returning varying results Pin
Eric Dahlvang21-Sep-06 11:23
Eric Dahlvang21-Sep-06 11:23 
GeneralRe: Design question - returning varying results [modified] Pin
Eric Dahlvang22-Sep-06 3:26
Eric Dahlvang22-Sep-06 3:26 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango22-Sep-06 5:38
sponsorJudah Gabriel Himango22-Sep-06 5:38 
GeneralRe: Design question - returning varying results Pin
Eric Dahlvang22-Sep-06 6:17
Eric Dahlvang22-Sep-06 6:17 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango22-Sep-06 6:28
sponsorJudah Gabriel Himango22-Sep-06 6:28 
GeneralRe: Design question - returning varying results Pin
Scott Serl21-Sep-06 7:49
Scott Serl21-Sep-06 7:49 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango21-Sep-06 8:39
sponsorJudah Gabriel Himango21-Sep-06 8:39 
GeneralRe: Design question - returning varying results Pin
Scott Serl21-Sep-06 9:03
Scott Serl21-Sep-06 9:03 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango21-Sep-06 10:00
sponsorJudah Gabriel Himango21-Sep-06 10:00 
GeneralRe: Design question - returning varying results Pin
Scott Serl21-Sep-06 10:27
Scott Serl21-Sep-06 10:27 
GeneralRe: Design question - returning varying results Pin
Judah Gabriel Himango21-Sep-06 18:01
sponsorJudah Gabriel Himango21-Sep-06 18:01 
QuestionRowFilter and Dataset Pin
Itanium21-Sep-06 2:28
Itanium21-Sep-06 2:28 
AnswerRe: RowFilter and Dataset Pin
Stephan Pilz21-Sep-06 21:06
Stephan Pilz21-Sep-06 21:06 
QuestionVisual Query Builder Pin
BadKarma21-Sep-06 2:09
BadKarma21-Sep-06 2:09 
QuestionSQL Server CURSOR Pin
choorakkuttyil21-Sep-06 2:07
choorakkuttyil21-Sep-06 2:07 

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.