To enable users to have synonyms unique to their needs and still keep table maintenance at an acceptable level, consider creating several views of one synonym table, and assigning the views to individual users or groups of users. There are three types of views you can create.
If you have few synonyms that are used by individuals, consider creating and assigning a view that flags each synonym for either public use (by all users) or private use (by individual users):
CREATE VIEW SYNVIEW (VERB,OBJECT,SYNONYM__DEFINITION) AS SELECT VERB, OBJECT, SYNONYM__DEFINITION FROM COMMAND__SYNONYMS WHERE AUTHID='userid' OR AUTHID IS NULL
If you support a large group of end users, consider creating and assigning a view that flags certain synonyms to be used by certain groups of users.
The synonym table used to create the view contains a single row for each synonym that belongs to a user group, and a single row for each public synonym. AUTHID is either null or has a value that uniquely identifies the user group.
CREATE VIEW GROUPVIEW (VERB,OBJECT,SYNONYM__DEFINITION) AS SELECT VERB, OBJECT, SYNONYM__DEFINITION FROM COMMAND__SYNONYMS WHERE AUTHID='DEPTD02' OR AUTHID IS NULL
Consider creating a separate table that holds in one column SQL authorization IDs and in the other column the values of a key. If the keyed value for a particular SQL authorization ID matches a keyed value in a row of the command synonym table, the synonym described in that row is available to the user.
Use a query similar to the one in Figure 147 to implement this method of maintaining command synonyms. The query creates a view called KEYVIEW on the table COMMAND__SYNONYMS, incorporating in the view only the synonyms that have keyed matches between COMMAND__SYNONYMS and the auxiliary table, KEYTABLE.
CREATE VIEW KEYVIEW (VERB,OBJECT,SYNONYM__DEFINITION) AS SELECT VERB, OBJECT, SYNONYM__DEFINITION FROM COMMAND__SYNONYMS WHERE AUTHID IS NULL OR AUTHID IN (SELECT KEYS FROM KEYTABLE WHERE USER=userid)