def addRelationship(self, tab_foreign_name, tab_foreign_key, 
                        tab_primary_name, tab_primary_key,
                        rel_name, cascade_del=False, 
                        cascade_update=False):
        """
        Add primary table-foreign table relationship        
        """
        tabs = [tab_foreign_name, tab_primary_name]
        for tab in tabs:        
            if tab not in self.getTableNames():
                raise Exception, "Table \"%s\" is not in this database" \
                    % tab
        cat = win32com.client.Dispatch(r'ADOX.Catalog')
        cat.ActiveConnection = self.connAccess
        tbl_foreign = cat.Tables(tab_foreign_name)
        new_key = win32com.client.Dispatch(r'ADOX.Key')
        try:
            new_key.Name = rel_name
            new_key.Type = AD_KEY_FOREIGN
            new_key.RelatedTable = tab_primary_name
            new_key.Columns.Append(tab_foreign_key)
            new_key.Columns(tab_foreign_key).RelatedColumn = tab_primary_key
            if cascade_del:
                new_key.DeleteRule = AD_RI_CASCADE
            if cascade_update:
                new_key.UpdateRule = AD_RI_CASCADE
            tbl_foreign.Keys.Append(new_key)
        except Exception, e:
            raise Exception, "Unable to add relationship '%s'. " % \
                rel_name + "Orig error: %s" % str(e)
        finally:
            tbl_foreign = None
            cat = None

        Add primary table-foreign table relationship        
        
recipes/Python/528868_Extractimanipulaticlass_Microsoft/recipe-528868.py