Click here to Skip to main content
16,005,236 members
Home / Discussions / Database
   

Database

 
AnswerRe: data type for saving long decimal Pin
Sathesh Sakthivel10-Jul-07 20:21
Sathesh Sakthivel10-Jul-07 20:21 
GeneralRe: data type for saving long decimal Pin
N a v a n e e t h10-Jul-07 21:10
N a v a n e e t h10-Jul-07 21:10 
AnswerRe: data type for saving long decimal Pin
N a v a n e e t h10-Jul-07 21:12
N a v a n e e t h10-Jul-07 21:12 
AnswerRe: data type for saving long decimal Pin
Krish - KP11-Jul-07 1:11
Krish - KP11-Jul-07 1:11 
QuestionSQL WHERE > for text Pin
Pseudocaine10-Jul-07 10:01
Pseudocaine10-Jul-07 10:01 
AnswerRe: SQL WHERE > for text Pin
_Damian S_10-Jul-07 14:24
professional_Damian S_10-Jul-07 14:24 
AnswerRe: SQL WHERE > for text Pin
Krish - KP10-Jul-07 17:46
Krish - KP10-Jul-07 17:46 
QuestionData modeling - file-system type of hierarchy Pin
dandy7210-Jul-07 7:11
dandy7210-Jul-07 7:11 
Hi all,

I'm trying to create a "generic" hierarchical model to store simple parent/child relationships. The closest approximation to what I'm trying to end up with is strongly based on the file system model. In SQL, I've defined the following table:

- ID (auto-generated, unique, non-nullable)
- NAME (just a string to be displayed to the user)
- PARENT_ID

The one fundamental constraint above all others I want to enforce at the database level is that any PARENT_ID value, if it has a non-NULL value at all, must exist somewhere in the ID field in this table. There are other restrictions that would be nice to have, but I can live with having this one only as a starting point.

Ultimately, I want to be able to store something like this:

C:\TEST1\FOLDER1
C:\TEST1\FOLDER2
C:\TEST1\FOLDER2\SUBFOLDER1
C:\TEST2\FOLDER1

...as:

1, "TEST1", NULL
2, "FOLDER1", 1
3, "FOLDER2", 1
4, "SUBFOLDER1", 3
5, "TEST2", NULL
6, "FOLDER1", 5

For some reason, suggesting this sort of thing in primarily SQL-oriented newsgroups seems to make the natives want to break out the tar and feathers...I'm apparently "thinking too much like an older developer used to linked lists and pointers". Fine, maybe I can't see the forest for the trees, but this "simple" model (in my eyes), if I can get it to work, would provide me with all the flexibility I need.

Ultimately, I'm NOT interested in writing any convoluted recursive queries to walk back up the PARENT_ID chain for a given node/row. The most complicated thing I might do is draw a tree (in ASP.NET), starting at the top level only (listing those entries whose PARENT_ID is NULL), and fetch a node's children when that node is clicked (select those entries whose PARENT_ID matches the ID of the node clicked).

Is this approach going to work, or do I have to scrap this entirely and put myself through hundreds of pages of data modeling theory, as the SQL gurus elsewhere seem to be suggesting?

If this is workable, could some kind soul *please* show me a SQL script to create this table with the appropriate constraints in place--or at least tell me what to click in SQL Server 2005 Management Studio to establish the constraints. I can't figure that part out (defining the table is easy, it's defining the "must exist in the ID column" rule for the PARENT_ID column I'm struggling with).

I'll save the "what's with the animosity among SQL developers towards old-fashioned software developers" question for another thread...
AnswerRe: Data modeling - file-system type of hierarchy Pin
dandy7210-Jul-07 10:44
dandy7210-Jul-07 10:44 
QuestionRetrieve random rows in Access Pin
Red Lake10-Jul-07 5:56
Red Lake10-Jul-07 5:56 
AnswerRe: Retrieve random rows in Access Pin
Paul Conrad10-Jul-07 7:21
professionalPaul Conrad10-Jul-07 7:21 
GeneralRe: Retrieve random rows in Access Pin
Red Lake10-Jul-07 7:25
Red Lake10-Jul-07 7:25 
GeneralRe: Retrieve random rows in Access Pin
Paul Conrad10-Jul-07 8:01
professionalPaul Conrad10-Jul-07 8:01 
GeneralRe: Retrieve random rows in Access Pin
Red Lake10-Jul-07 8:06
Red Lake10-Jul-07 8:06 
GeneralRe: Retrieve random rows in Access Pin
Paul Conrad10-Jul-07 8:10
professionalPaul Conrad10-Jul-07 8:10 
AnswerRe: Retrieve random rows in Access Pin
sam#10-Jul-07 8:22
sam#10-Jul-07 8:22 
GeneralRe: Retrieve random rows in Access Pin
Red Lake11-Jul-07 3:30
Red Lake11-Jul-07 3:30 
GeneralRe: Retrieve random rows in Access Pin
Paul Conrad13-Jul-07 6:12
professionalPaul Conrad13-Jul-07 6:12 
GeneralRe: Retrieve random rows in Access Pin
Red Lake16-Jul-07 2:36
Red Lake16-Jul-07 2:36 
GeneralRe: Retrieve random rows in Access Pin
Paul Conrad16-Jul-07 7:31
professionalPaul Conrad16-Jul-07 7:31 
QuestionDatasets and varaible table name Pin
joebaas10-Jul-07 3:27
joebaas10-Jul-07 3:27 
AnswerRe: Datasets and varaible table name Pin
Paul Conrad13-Jul-07 11:50
professionalPaul Conrad13-Jul-07 11:50 
GeneralRe: Datasets and varaible table name Pin
joebaas16-Jul-07 5:14
joebaas16-Jul-07 5:14 
Questioncancel inner join Pin
Amr M. K.10-Jul-07 1:02
Amr M. K.10-Jul-07 1:02 
AnswerRe: cancel inner join Pin
gauthee10-Jul-07 2:04
gauthee10-Jul-07 2:04 

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.