need help designing a database table (or tables) to hold a hash (%config) and ( %group)

need help designing a database table (or tables) to hold a hash (%config) and ( %group)

am 22.04.2011 18:47:33 von Agnello George

Hi All

i am creating a script for deployment of websites and i need to create
hash %config ( which stores a lot of configurations setting for
each type of website ) ... i have been manually eaditing this hash
but now the hash has to now be generated from a a database ( mysql )
.... i have never worked with designing a database structure . Can
any one guide me how to go about it .


my hash structure looks some thing like this

my %config = ( 'website_auto_1' => {
'group' => 'website_auto_group1',
'tempdir' => '/var/www/html/temp/auto' ,
'svnurl' => 'http://svn.intranet.com/repos/branch/auto',
'excludes' =>
'uploaded_images|includes/config.php|admin/includes/config.p hp|.svn',
'tarpath' => '/var/www/html/temp/autotar/',
'tarname' => 'auto',
'rmtrootdir' => '/var/www/projects/auto',
'rmttmpdir' => '/temp/auto',
'rmteserver' => '192.168.1.26' },

website_auto_2 => { ....
:
:
) ;

%group = ( website_auto_1 => { auto_group => [ name => user1 , name
=> user2 , name => user6 ] },
website_auto_2 => { auto_group => [ name => user2 ,
name => user5 ] }, ...
:
:
);

i am not too sure if the %group ( not really implement this ) hash is
correct , but i what i want to do is , my deployment script should
only allow users who are logged in to deploy a particular website (
eg website_auto_1 ) if they belong to the group .


thanks in advanced






--
Regards
Agnello D'souza

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/

Re: need help designing a database table (or tables) to hold a hash (%config) and ( %group)

am 22.04.2011 19:58:51 von Shawn Wilson

first, this isn't the proper forum. second...

On Fri, Apr 22, 2011 at 12:47 PM, Agnello George
wrote:
> Hi All
>
> i am creating a script for deployment of websites and i need to create
> =A0hash =A0 =A0%config ( which stores a lot of configurations setting for
> each type of website ) =A0... i have been manually =A0eaditing this hash
> but now the =A0hash =A0has to now be generated from a a database ( mysql =
)
> ... i have =A0never worked =A0with designing a database structure . Can
> any one guide =A0me how to go about =A0it =A0.
>
>
> my hash structure looks some thing like this
>
> my %config  = ( 'website_auto_1' =3D> {
> =A0 =A0 =A0 'group' =3D> 'website_auto_group1',
> =A0 =A0 'tempdir' =3D> '/var/www/html/temp/auto' ,
> =A0 'svnurl' =3D> 'http://svn.intranet.com/repos/branch/auto',
> =A0 'excludes' =3D>
> 'uploaded_images|includes/config.php|admin/includes/config.p hp|.svn',
> =A0 'tarpath' =3D> '/var/www/html/temp/autotar/',
> =A0 'tarname' =3D> 'auto',
> =A0 =A0'rmtrootdir' =3D> '/var/www/projects/auto',
> =A0 =A0'rmttmpdir' =3D> '/temp/auto',
> =A0 =A0'rmteserver' =3D> '192.168.1.26' },
>
> website_auto_2 =3D> { ....
> :
> :
> ) ;
>
> %group =3D ( =A0website_auto_1  => { auto_group =3D> [ name =3D> user=
1 , name
> =3D> user2 , name =3D> user6 ] },
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0website_auto_2  => { auto_group =
=3D> [ name =3D> user2 ,
> =A0name =3D> user5 ] }, ...
> :
> :
> );

this makes no sense to me.

>
> i am not too sure if the %group ( not really implement this ) =A0hash is
> correct , but i what i want to do is , my deployment script should
> only allow users who are logged in =A0to deploy a particular website (
> eg website_auto_1 ) =A0if they belong to the group .
>

ok, now we might be getting somewhere, you want user groups and object grou=
ps?

so give your objects gids. i generally do unsigned int auto_increment
primary key.
then, give your users uids. same theory.
then, your objects (web sites?) get gids.... or, in mysql, just do it
(what i consider) right like this:

CREATE TABLE report (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
edate INT UNSIGNED,
mdate INT UNSIGNED,
duedate INT UNSIGNED,
gid INT,
uid INT UNSIGNED,
FOREIGN KEY( gid ) REFERENCES grp( gid ),
FOREIGN KEY( uid ) REFERENCES grp( uid )
)

CREATE TABLE user (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
uname VARCHAR(10),
pass VARCHAR(50),
fname VARCHAR(15),
lname VARCHAR(15),
email VARCHAR(50),
org VARCHAR(50),
telph INT UNSIGNED,
celph INT UNSIGNED,
officeph INT UNSIGNED,
mainph INT UNSIGNED,
cdate INT UNSIGNED,
edate INT UNSIGNED,
enabled BOOL
)

CREATE TABLE gname (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30)
)

CREATE TABLE grp (
id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
uid INT UNSIGNED,
gid INT,
FOREIGN KEY (uid) REFERENCES user( id ),
FOREIGN KEY (gid) REFERENCES gname( id )
)


this is what i'm using that seems to work decently. and as you can
see, i store other information for my users. my 'report' would be your
web page. you might want to do other things, but this is ot enough.
ask for more explanation in a better forum for this. btw, you'll need
to do some reading up on dbi or dbic to be able to use this in perl.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/