Tables created by web2py use the "id" field as the primary key, so reference fields set a foreign key constraint referencing the "id" field.
If the primary key in your legacy database table is an auto-incrementing integer field but just doesn't happen to be named "id", you can still have web2py use that field as the primary key by specifying the "id" field type:
db.define_table('legacy_table',
Field('my_id', 'id'), ...)
However, if the primary key is not a single auto-incrementing integer field, you should instead look at the documentation on keyed tables. You can specify the primary key of the table, in which case, web2py will not create or expect an "id" field. However, there are some limitations in functionality.