Hi all,

I've read the book 'Practical Web 2.0 Applications with PHP' and in
that book the author uses a different database modeling.
I'll give you an example, if you have a 'users' table with a lot of
columns like, first name, last name, country, food, etc... He suggests
that you create 2 tables, called 'users' and 'users_profile":

- users table:
user_id
username
password
...

- users_profile
user_id
profile_key
profile_value

So... if you have to insert the user's country, you insert into
users_profile table: (7162, 'country', 'brazil')...

So, the author give us two classes to manipulate the user object and
profile (DatabaseObject and Profile classes).
If you want to get the user's country you use:

$user = new DatabaseObject_User();
$user->load(7162); //the user id
echo $user->profile->country; //will print 'brazil'

It's good because you can insert a lot of information without change
the database table.. only adding a new property in the user class.

What do you think about this new modeling? Have you used this?
Detail: if you have to sum double numbers, for example, the mysql did
the sum normally.

Thanks.

Junior Grossi
[EMAIL PROTECTED]

Reply via email to