Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Using DBIC: What is the correct way to design relationships for Role Based Authorization?

by three18ti (Scribe)
on Jun 04, 2012 at 18:53 UTC ( #974355=perlquestion: print w/ replies, xml ) Need Help??
three18ti has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am wokring on building a website, because I don't really understand how DBIC works it was suggested that I take Catalyst out of the equation and build my database first.

I would like to write my relationships first, then using a script deploy my DB and (if necessary) pre populate it. Doing it via scripted interface will allow for more flexibility in deployment as well as DB choice.

I have been working on this and you can see my full source at https://github.com/three18ti/dbix-schema-test. I did post about an error I am receiving in a previous post DBIC Error: DBIx::Class::PassphraseColumn::new(): new_result needs a hash at constructor but it seems that it is a rare error to encounter.
Can someone please provide some pointers on how to correctly design a DB schema using DBIC?

Thanks.

Comment on Using DBIC: What is the correct way to design relationships for Role Based Authorization?
Re: Using DBIC: What is the correct way to design relationships for Role Based Authorization?
by DrHyde (Prior) on Jun 06, 2012 at 10:46 UTC

    I suggest designing the database first, including all the foreign key relationships, and only after you've done that should you create your DBIx::Class stuff.

    To answer your specific question how to design the relationships for role-based authentication, I suggest three tables:

    user
    id, username, password_hash, etc ...
    role
    id, name
    user_role
    user_id, role_id
    I'm sure that the meanings of all these field names and the relationships between them are obvious. If it isn't, then you should first read a book on relational databases.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://974355]
Approved by kcott
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (17)
As of 2015-07-06 14:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (75 votes), past polls