Linked list ?

Results 1 to 2 of 2

Thread: Linked list ?

  1. #1
    Join Date
    Dec 1969

    Default Linked list ?

    I have a relational database which contains fields with some data and a field which holds the recordID of the next record [nextID].<BR>Now I want to retrieve the records in the [nextID] order. <BR>In C/C++ this is known as the "linked list". <BR>Is there a way to do this in ASP, or what is the best way to do it.<BR><BR>I was planning to put them all in an array, but then I get stuck on what to do next.<BR><BR>TIA<BR>BaKMaN

  2. #2
    Join Date
    Dec 1969

    Default Well, it's bad DB design... start with. Because it means you can&#039;t use SQL to (for example) produce an ordered list.<BR><BR>But never mind.<BR><BR>Actually, in C/C++ this is *NOT* a true linked list. It&#039;s just an array with element references. Because the individual objects in the list aren&#039;t truly independent. If you were to read the records in one at a time and create a new object for each and link the objects via *POINTERS*...yeah, then it would be a true linked list.<BR><BR>But that&#039;s quibbling.<BR><BR>Okay, I give up. Why can&#039;t you do the same thing with VBScript???<BR><BR>You have an array of records and you use the link in one record to find the record, by id, in the array.<BR><BR>How is this different than what you&#039;d do in C/C++? Assuming you didn&#039;t go to the trouble to create objects and use pointers in C/C++?<BR><BR>If the record id&#039;s are sequential, this is trivial: Each id corresponds directly to a slot in the array (may need an offset, but it&#039;s a direct correspondence). But if there are gaps in the record id&#039;s then how do you handle it?<BR><BR>Ask yourself how you would handle this in C/C++. Tell me your answer and it will be easy to translate it to VBScript (or JScript, if you prefer).<BR><BR>But I&#039;d give serious consideration to redesigning the DB structure, so that you could use SQL queries to do the ordering.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts