[Dbix-class] more newbie questions

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Thu Feb 28 10:15:27 GMT 2008


On 28 Feb 2008, at 09:51, Dermot wrote:
> 1) I have been using the MySQL workbench tool to try and make a ER  
> diagram of a database. The community edition doesn't allow printing  
> but is excellent in every other way. Could anyone recommend a  
> similar tool? I hear Dia is a good OS tool.

Given a db or DBIC description, there are some tools in  
SQL::Translator to  spit out ER diagrams.

> 2) I posted a query about the Catalyst tutorials and that fact that  
> the used a join table to show many to many relationships between  
> authors and books. Is this type of table what is termed a view? Or  
> am I still not getting it :-(

Not a view - those are the table like things you can produce with  
CREATE VIEW ...

The problem is that you can do a many-to-one or one-to-many  
relationship by having the many item contain a foreign key to the one  
item.  However there is no such neat method to do a many-to-many  
relationship, so you have to break it down to be a pair of  
relationships - a many-to-one-to-many combination with the link table  
in the middle consisting of foreign keys to the other pair of tables.

As an example, for a theatre event (as in show) handling db I have,  
each show has 0 or more ticket agencies selling tickets.  The ticket  
agencies are re-used for many events (so a place in town will sell  
tickets for many events).

Hence I have an "event" table
and a "ticket_agent" table
and a "event_ticket_agent" table - this one purely consists of 2  
fields - the event id and the ticket_agent id, and links the pair.

I refer to that as a link table, but I am a sysadmin rather than a DB  
expert :-)

Hope that helps a bit.

	Nigel.


--
[ Nigel Metheringham             Nigel.Metheringham at InTechnology.com ]
[ - Comments in this message are my own and not ITO opinion/policy - ]






More information about the DBIx-Class mailing list