PDA

View Full Version : DB design for rewriting URL



Nico
05-02-2006, 08:31 PM
Hi,

Im building a site that will have profiles of some people, but im having some doubts about how to implement some things.

- I want to store the first and a last name for each person, i was thinking on having each on separate fields. That way i can list only the first or last name when needed. You think it's a good idea or it would be better to put them the 2 in one field?

- I'll also be using mod_rewrite to rewrite the URL's, using the first & last name to link to each profile (instead of a numeric id). I'll still use an ID, but just for internal use (like deleting records,etc).
How should i do this? Just make the ID a primary key, and first & last UNIQUE? Or should i make first & last name the primary key?

- How should i show the rewrite URL...
www.mysite.com/firstname_lastname
or
www.mysite.com/firstname lastname
?

- And of course, im going to put a search feature...any advantage on using Full text searching if im just going to search through a first & last name? Maybe it's just better to use %LIKE% ?

I would appreciate any suggestion!

Chris
05-03-2006, 05:32 AM
Well, I do this as such:

1. Separate fields for first & last names.
2. a numeric key field for the primary key, internal use as you said
3. a textid field that has a unique textid I use for the SE friendliness.

I do it this way because there is the odd person with a weird name that I might not want in the URL.

If you do just want to use first&Last in your URLs, use a hyphen not a space or an underscore to separate them.

ses5909
05-03-2006, 05:37 AM
Well, I do this as such:

1. Separate fields for first & last names.
2. a numeric key field for the primary key, internal use as you said
3. a textid field that has a unique textid I use for the SE friendliness.

I do it this way because there is the odd person with a weird name that I might not want in the URL.

If you do just want to use first&Last in your URLs, use a hyphen not a space or an underscore to separate them.

Such as o'malley

Nico
05-03-2006, 01:39 PM
Let me see if i understood your point 3:
You mean you create a separate text field, make it unique, enter manually a 'code' name (which it can be the first name or last or an abbreviation) and use it for SE friendliness.
So the URL will not use the first & last name, but instead this textid field, right?

That's interesting. I didn't think of that.

Thanks! :thumbs_up

Nico
05-05-2006, 07:04 AM
If you do just want to use first&Last in your URLs, use a hyphen not a space or an underscore to separate them.
I noticed that in your articles you use a underscore to separate words: http://www.websitepublisher.net/website_promotion/search_engine_optimization/
Wikipedia also uses underscores: http://en.wikipedia.org/wiki/United_states_of_america

If hyphens are better, why both use underscores? Maybe both did it that way in the past and was hard to change later.