Welcome Guest, Not a member yet? Register   Sign In
CRUD : url identification of an item by number or by id?
#1

[eluser]NemetraL[/eluser]
Hello,

Just a quick poll to know what you generally use to point an item using the URL in a CRUD-like web application (for example an online gallery) %-P

As you may know, the number is most likely different from the ID: let's say you create 5 pictures from scratch in this gallery, the five ID will exactly match the numbers like:

ID: #
1 : 1
2 : 2
3 : 3
4 : 4
5 : 5

Then if you delete picture number 3, the IDs will no longer match the numbers starting from entry 3 on:

ID: #
1 : 1
2 : 2
4 : 3
5 : 4

And so on..

When you display all the pictures in a web page, you'll index the results by number (not by ID, otherwise it will look chaotic). But when you want to display one particular picture, will you access the entry using the number or the ID in the URL?

1st solution: using www.site.com/gallery/item/ID
pro: unique identification (you can share the URL)
con: inconsistency with the indexation on the web page displaying all the pictures

2nd solution: using www.site.com/gallery/item/number
pro: consistency with the indexation on the web page displaying all the pictures
con: URL not able to be shared since the number of the picture may change at anytime according to its position

So far I tend to use the 1st solution for public applications (an online photo gallery) and the 2nd one for private admin interfaces since there's no reason so share URLs.

What about you?
#2

[eluser]Michael Wales[/eluser]
3rd solution - don't use numbers and merely rely on ID

I usually don't use an ID at all and use slugs (url_title($myvar)) - helps on the SEO front.




Theme © iAndrew 2016 - Forum software by © MyBB