Re: PHP-mysql better way to build a pyramid table
| From: | Doug Semig | Date: | Thu, 30 Nov 2000 15:49:12 +0000 |
| Subject: | Re: PHP-mysql better way to build a pyramid table | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-4894@lists.php.net to get a copy of this message | ||
This is more commonly done in a single table instead of two tables.
Doug
At 03:45 PM 11/30/00 +0200, Uioreanu Calin wrote:
>Hello,
>
> I want to create through a few number of tables with fewest records
>a pyramid structure like this: a new person cames into the person's
>table reffered by another one. There are fields for direct reffered persons
>and total refferals from each existing person in person's table. So each
>new person increases his (parent's) direct reffered persons and each
>of his parent's parent's and grandparents and ... total refferals.
>
> I builded these tables:
>CREATE TABLE tbl_mlm_users (
> username varchar(50) NOT NULL,
> userpass varchar(50) NOT NULL,
> personal_refferals int(11) DEFAULT '0' NOT NULL,
> total_refferals int(11) DEFAULT '0' NOT NULL,
> iduser int(11) NOT NULL auto_increment,
> userfullname varchar(50) NOT NULL,
> useradress varchar(50) NOT NULL,
> useremail varchar(50) NOT NULL,
> PRIMARY KEY (iduser)
>);
>&
>CREATE TABLE tbl_mlm_refferals (
> iduser_parent int(11) DEFAULT '0' NOT NULL,
> iduser_child int(11) DEFAULT '0' NOT NULL,
> ref_time varchar(20) NOT NULL,
> PRIMARY KEY (iduser_parent, iduser_child)
>);
>
>
> where id.. points to the other table for details.
>ref_time is the time when the reffer occurs.
>
> Is there a better way of doing that?
>
>--
>Regards,
>------------------------------------------------------
>Calin Uioreanu
>udmsromkt@mail.dntcj.ro
>DMS Team Cluj-Napoca Romania
>-----------------------------------------------------