|
Posted by Jerry Stuckle on 06/30/05 18:48
madsgormlarsen@gmail.com wrote:
> Hi
>
> I do not understand all of it, for exsample you write
>
>
>>Think - normalize, normalize, normalize.
>
>
>>Think - 4 columns - one for each >language. What happens if you need to
>>add a fifth language? How much code >will you have to change?
>
>
> Which is what Jeff has one column for each language, but if what you
> are suggesting is
Yes, and adding a new language means you need to modify the database itself.
>
> CREATE TABLE `usr_languages` (
> `pageName` varchar(25) default '',
> `language` char(2),
> `Actual_info` text,
> )
>
> then you would get rows for each language.
>
Yes. And adding a new language means NO database changes.
> I rellay find it amazing that wrox or reiley do not seem to have a book
> covering this specific issue.
>
Not really. Relational database design has been rather limited in its
application. And normalization is actually quite a simple concept to grasp
(although not always as easy to implement in complicated instances).
I used to teach a DB2 course (corporate clients). It was a five day course
which included normalization. The normalization section was less than an hour
long plus a short paper lab. Not really enough material for a book.
> I have done a lot of googling on the subject but the best I have found
> is short forum answers.
>
You won't find normalization answers in this newsgroup. However, a quick google
search turned up among others:
http://www.utexas.edu/its/windows/database/datamodeling/rm/rm7.html
http://en.wikipedia.org/wiki/Database_normalization
http://www.cs.sfu.ca/CC/354/zaiane/material/notes/Chapter7/node1.html
The first is the easiest to understand and covers the first three levels of
normalization. There are fourth and fifth normal designs, but most databases
don't go that far - third normal is the general rule.
The second goes through the fourth and fifth normal forms also, but isn't quite
as detailed as the first. The third one covers a lot more theory and is harder
to understand - but I included it for those who might be interested.
<code snipped>
You can do it this way. But can I make another suggestion? Perhaps instead of
trying to dynamically build what is basically static text - just have different
directories for each language, and different pages? Yes, its some duplication -
but if you 're not constantly updating a lot of pages, it might be easier.
For instance -
http://www.mysite.com/en - English
http://www.mysite.com/fr - trench
http://www.mysite.com/sp - Spanish
And so on. I've done this for multilingual sites (English/Spanish) and it works
well. Yes, it means if you need to make a change you need to change multiple
pages - but once you have the first page working the rest go quite quickly.
Otherwise, if you do want this to be dynamic, I suggest you place all
language-dependent things in the database. For instance, if you want a page
which says "hello", you could design your database such as:
language char(2)
pagename varchar(255)
fieldnum smallint
data text
And your entries could be something like:
'en', 'hellopage', 1, 'Hello, world!'
'sp', 'hellopage', 1, '?Hola, el mundo!'
'fr', 'hellopage', 1, 'Bonjour, le monde!'
However, if you're going to have multiple items such as for a select box, you
might want to consider more tables:
1st table
language char(2)
pagename varchar(255)
fieldnum smallint
fieldkey int
2nd table
fieldkey int
sequence smallint
data text
Or
1st table
pagename varchar(255)
fieldid smallint
language char(2)
fieldkey int
2nd table
fieldkey int
sequence smallint
data text
Or even
1st table
pagename varchar(255)
language char(2)
pagekey int
2nd table
pagekey int
fieldid smallint
sequence smallint
data text
Any of the three would work (and there are more) - but personally I'd lean
towards the third one based on this limited discussion. However, as I looked
more into the details, I might select one of the other two.
Also, in your way of doing things, if you want to carry the language between
pages, I might suggest using a session variable. I like it better.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|