Click here to Skip to main content
15,910,878 members
Home / Discussions / Database
   

Database

 
QuestionPlease assist to solve this problem Pin
pubududilena2-Oct-06 1:35
pubududilena2-Oct-06 1:35 
AnswerRe: Please assist to solve this problem Pin
Michael Potter2-Oct-06 4:37
Michael Potter2-Oct-06 4:37 
GeneralRe: Please assist to solve this problem Pin
pubududilena3-Oct-06 19:47
pubududilena3-Oct-06 19:47 
GeneralRe: Please assist to solve this problem Pin
Michael Potter4-Oct-06 4:00
Michael Potter4-Oct-06 4:00 
QuestionOrdering a linked list Pin
Rob Philpott1-Oct-06 23:34
Rob Philpott1-Oct-06 23:34 
AnswerRe: Ordering a linked list Pin
Colin Angus Mackay2-Oct-06 0:41
Colin Angus Mackay2-Oct-06 0:41 
GeneralRe: Ordering a linked list Pin
Rob Philpott2-Oct-06 1:11
Rob Philpott2-Oct-06 1:11 
GeneralRe: Ordering a linked list Pin
Colin Angus Mackay2-Oct-06 2:01
Colin Angus Mackay2-Oct-06 2:01 
Rob Philpott wrote:
Why do you say this isn't really what Sql is designed to do? It seems perfectly acceptable, desirable even (well to me at least!) to have an abstraction where a database can maintain a linked list of data. My operations would be 'return in order', 'delete item in list', 'insert item in list'.


Because SQL is a set based language. It operates more efficiently on small numbers of large set operations rather than large numbers of small set operations.

Traversing a linked list requires a large number of small set operations. e.g. Each SELECT is a set based operation. If you have to traverse a linked list you need to perform a large number of select operations. If you have an Order column in the table then you just need one SELECT statement with an ORDER BY clause.

Remember also, that a linked list is really just an implementation detail of one way to store a set of data. It is useful in certain scenarios. I used linked lists many-a-time when I programmed in C++, but I also used arrays when the need arose.

To get around the insert and delete problem while holding an Order column. the Order column could increment by 2. An insert would put the new row with an odd number (first set based operation), Immediately after, if you are using SQL Server 2005, you could renumber the Order column by using the row numbering feature and multiplying the result by 2 to get the new value of the Order column (second set based operation). Delete operations don't actually have to re-order anything as the Order column is just for ordering and nothing else. Insert operations now trade off some of the speed they once had (because large tables will still take some time) for much faster speed on iteration.

As it stands the WHILE loop suggestion I gave before will have (on anything more than a handful of rows) unacceptable iteration performance when getting the data out. (Large numbers of small set operations)


GeneralRe: Ordering a linked list Pin
Rob Philpott2-Oct-06 3:01
Rob Philpott2-Oct-06 3:01 
GeneralRe: Ordering a linked list Pin
Colin Angus Mackay2-Oct-06 8:04
Colin Angus Mackay2-Oct-06 8:04 
GeneralRe: Ordering a linked list Pin
Colin Angus Mackay2-Oct-06 8:07
Colin Angus Mackay2-Oct-06 8:07 
QuestionLargest Data Typein SQL Server Pin
King Shez1-Oct-06 21:08
King Shez1-Oct-06 21:08 
AnswerRe: Largest Data Typein SQL Server Pin
albCode1-Oct-06 21:25
albCode1-Oct-06 21:25 
AnswerRe: Largest Data Typein SQL Server Pin
Mark Salsbery4-Oct-06 11:02
Mark Salsbery4-Oct-06 11:02 
Questionsql server 2005 Pin
amaneet29-Sep-06 20:21
amaneet29-Sep-06 20:21 
AnswerRe: sql server 2005 Pin
zhengdong jin30-Sep-06 7:32
zhengdong jin30-Sep-06 7:32 
QuestionReplication cursor [modified] Pin
Skanless29-Sep-06 16:18
Skanless29-Sep-06 16:18 
AnswerRe: Replication cursor Pin
Skanless29-Sep-06 21:46
Skanless29-Sep-06 21:46 
QuestionT-SQL Syntax Pin
lakshmi_sri29-Sep-06 11:02
lakshmi_sri29-Sep-06 11:02 
AnswerRe: T-SQL Syntax Pin
zhengdong jin29-Sep-06 19:53
zhengdong jin29-Sep-06 19:53 
Questionshow records horizontally Pin
jlizardo29-Sep-06 5:32
jlizardo29-Sep-06 5:32 
AnswerRe: show records horizontally Pin
Elina Blank29-Sep-06 8:12
sitebuilderElina Blank29-Sep-06 8:12 
QuestionRe: show records horizontally Pin
jlizardo29-Sep-06 9:40
jlizardo29-Sep-06 9:40 
AnswerNot too hard Pin
Ennis Ray Lynch, Jr.2-Oct-06 15:51
Ennis Ray Lynch, Jr.2-Oct-06 15:51 
QuestionPlease help me Pin
honeyman_can29-Sep-06 3:50
honeyman_can29-Sep-06 3:50 

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.