See below...

On 3/23/02 2:20 PM, "[EMAIL PROTECTED]"

> From: "Ljungan" <[EMAIL PROTECTED]>
> Date: Sat, 23 Mar 2002 11:17:15 +0100
> Subject: Re: [PHP-DB] "marking" DB entries...
> Thanks Frank!
> Just to be certain, cant I
> < If two users enter the same address
>> you will have two different records in the address table - identical
> except
>> for the authority field.
> store the information and just update the authority field? i.e  If the are
> two fields that look the same (made by user1 and user2) I want them to
> become one and just update the authority field so that it would look like
> authority="user1,user2". Is that possible or is that to much trouble? I dont
> have ANY experience about databases so I dont really know what is most
> common to do. But for sure, the sollution you gave me seems very easy,
> almost to easy =). I kept thinking about storing in the same field, hehe!
> thanks again!
> /Ljungan

The short answer is you can't.  The longer answer is you can but don't,
you're asking for trouble...

It violates one of the rules of data normalization.  I forget which one - if
you have no experience with DB's and want to learn something do a web search
on "data normalization" maybe include "rules" (** Yes DBA types are a pretty
anal bunch and they did number their rules **).

But basically you would have one of these problems:

-when user 2 updates that record the authority field gets set to him and
user 1 can't see the record anymore.

-if you put each user in the authority field (as you suggest) it won't
scale; you have authority="user1,user2" which might work although now the
SQL cannot use '=' (which is fast and can use indexes) and it has to use:
  authority like "%user2%"  // %'s are wild cards and cannot use indexes

-what happens if you have 50 or 200 users who all reference one address?
Can the field authority hole that much text?  How many would be the limit?
You'd have to write some complex code to handle when the number of users
goes over that limit.

You have a 'one to many' scheme here; many addresses are owned by one user;
that's simple and works well. If you did want to do groups where several
people have authority to view the several of the same records you'd call
that a 'many to many' relationship and it's traditionally solved with three

Adress    Users        Authority
------    ------       ----------
 addID    userID       userID
 name     name         addID
 address  password
 ....     ....

Where if Address #1 (addID = 1) could be edited by Users 3, 5 and 7 there
would be three records in the Authority table 3,1  5,1 and 7,1.  Now you'd
join all three, get the userID from your users login, joined to the
Authority table will get the addID's they can edit and now joined to the
Address table will only get the records they can edit.

If you want to do groups that's how to do it.

Good Luck,

PHP Database Mailing List (
To unsubscribe, visit:

Reply via email to