Full Text Search, Site Search, Linked Tables

interactive | editorial | code | resource 
Demonstrations > Part 2 > Many-Many
 

Many-Many

Many-many relationships (linking 3 tables)

To illustrate how to set up Many-many relationships with QuickAdmin, we'll use the example of employees and their links to territories. Each employee may be linked to many territories, each territory may be linked to many employees.

These tables are involved:
Employees The Employees table.
EmployeeTerritories    A 'linking table' between Employees and Territories.
Territories The Territories table

We'll start by showing how Many-Many relationships can be included in a QuickAdmin search. This search box is set up to search for Employees who cover a given region. For example, entering Denver will bring up all employees who are linked to the Denver region.

Leave the box blank and click Search in order to return all employees:

Search
Enter Text:

Here's the code:

<Search>
    <QuickAdmin:Simple Runat=server ID="Simple1" NAME="Simple1">
        <QuickAdmin:Many2Many LocalField=EmployeeID ForeignTable=Territories ForeignKeyField=TerritoryID ForeignDataField=TerritoryDescription IntermediateTable=EmployeeTerritories IntermediateLocalKey=EmployeeID IntermediateForeignKey=TerritoryID Runat=server ID="Many2many1" NAME="Many2many1"/>
    </QuickAdmin:Simple>
</Search>
	

You can see that the Many-Many relationship is searched upon, with EmployeeTerritories being used as the intermediate (linking) table. (See diagram on right).


 
Demonstrations > Part 2 > Many-Many