PHP-mysql better way to build a pyramid table

From: Date: Thu, 30 Nov 2000 13:45:07 +0000
Subject: PHP-mysql better way to build a pyramid table
Groups: php.db 
Request: Send a blank email to php-db+get-4885@lists.php.net to get a copy of this message
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 -----------------------------------------------------

« previous php.db (#4885) next »