December 21, 2014 at 1:05 pm
Comments posted to this topic are about the item Linked lists
December 21, 2014 at 10:19 pm
This is a great solution, linked list idea adds complexity though. You can easily change the way you rank your songs and make Position column as float. Then you assign {1,2,3,4,5}. If you need to add an element between 4 and 5, you can just add a new item with position value 4.5.
When you need to show your playlist, all you need to do is to sort by position number.
December 22, 2014 at 3:50 am
natalie.ignatieva (12/21/2014)
This is a great solution, linked list idea adds complexity though. You can easily change the way you rank your songs and make Position column as float. Then you assign {1,2,3,4,5}. If you need to add an element between 4 and 5, you can just add a new item with position value 4.5.When you need to show your playlist, all you need to do is to sort by position number.
+1
Same here.
December 22, 2014 at 3:53 am
Another solution is adding a xml column to the PlayList table and add the execution order there. So, it's just ONE update on ONE column.
December 22, 2014 at 5:27 am
Note these two solutions aren't logically equivalent.
The one with explicit Order column allows to repeate a title in a playlist.
December 22, 2014 at 7:19 am
An interesting solution. The only issue I have is that the seems to be like premature optimization. We have created a very non-standard approach for a performance issue that doesn't exist. It was eluded to that a long list could be become a performance bottleneck but there are no performance checks to back that up. I would argue that is not too likely because even with 10,000 songs the standard style of using a PlayOrder column would be really fast. If this article had posted the performance analysis it would be have been much better.
Also, you might want to look at this article before using MERGE. http://www.mssqltips.com/sqlservertip/3074/use-caution-with-sql-servers-merge-statement/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
December 22, 2014 at 7:50 am
But, Coldplay, followed by the Pixies?!? Oh dear...
December 22, 2014 at 8:15 am
+1 on the interesting solution. I like the core approach of looking at the "predecessor" outside of having a integer delimited list. I have used something similar in the past in an attempt to remove RBAR from some repetitive processes.
December 22, 2014 at 9:06 am
Won't it will break if people put the same song in there twice?
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply