One to many relationships mysql DB

One to many relationships mysql DB

markehmarkeh Posts: 1Questions: 0Answers: 0
edited March 2012 in General
Hi all,

I've been trying various tools to help me generate datagrids to work with a few tables in a mysql database. I just wanted to check how datatables can handle one to many relationships before I start spending time learning how to use it, I've tried a few other tools and they haven't worked out for me.

Basically I need to produce a datagrid that would allow me to assign an employee to many groups and view the groups they are assigned to using the following tables:

Employee Table employee_ID

Group Table group_ID

EmployeeGroup Table employee_ID group_ID

I'm not quite sure how best to do this with datatables, could I produce a master-detail grid? Or is there another clever way to display the groups inline.

Any thoughts would be very much appreciated.

Thanks

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    edited March 2012
    DataTables doesn't really care about that data source - its a client-side script. So as long as you can construct an SQL query that will pull your data from multiple DB tables into the HTML table format that you want, DataTables will run just fine with it. Equally you could do the same with Javascript - you just need to pull the data out of your database :-)

    *edit* Rereading your question I see I didn't fully answer it above. Yes a master details grid is an option, or what I often do for that kind of thing is use ellipsis with a column in the table, so it would do something like "Groups: First, Second and 3 more (show)" or "Groups: First" and so on.

    Again, it doesn't matter too much to DataTables how you do this - if it is tabular data then DataTables should be able to handle it (there are a few exceptions such as colspan/rowspan in the tbody...)

    Allan
This discussion has been closed.