Hi Omidaze,
Sorry it took so long to get back to you. I've been rolling out upgrades so haven't been able to get on the forums for a while.
Primary keys are used as a unique identifier for database records. Foreign keys are used to ensure data integrity between tables. For example, menu items are held in micros.mi_def and the prices are held in micros.mi_price_def. You can't have a price without a menu item, so there's a cascading foreign key set on micros.mi_price_def that links the mi_seq column to the mi_seq column in the micros.mi_def table. This ensures that there can't be a record in the price table with a mi_seq value that does not exist in the menu item table.
In this case micros.mi_def is the parent table and micros.mi_price_def is the child.
Cascading means that when a record is deleted in the parent table, all records in the child table linked to that parent item will also be deleted.
If the FK isn't cascading, you'll get an error when you try to delete a parent record that has children. This is how most of the relationships in micros are set up.
Sometimes, through db corruption or careless dba queries, a parent will get deleted while there are still child records. These children are now orphans, with a link to a parent record that doesn't exist. It sounds like this is what you have going on.
The foreign keys are all named for the table they restrict. So CFK7DEV_DEF is a foreign key on micros.dev_def. You can see exactly what it is by logging into Sybase Central, selecting the table you want and going to the Foreign Key tab. The FK description will tell you what table it refers to and what columns are used in that link. For example:
CFK7DEV_DEF links the lan_node_seq and com_port_seq columns in the dev_def table to the matching columns in the com_port_def table. The query below will give you the records in the device table that are linked to com ports that don't exist. The rebuild should have omitted these records, but if you run it on the pre-rebuild db you should get results.
Code:
select *
from
micros.dev_def d left outer join
micros.com_port_def c on
d.lan_node_seq = c.lan_node_seq and
d.com_port_seq = c.com_port_seq
where
c.com_port_seq is null
I'd take a look at each foreign key, see what it links together and make sure everything looks ok in the configurator for that data. For the above example, take a look at the Com Ports in the Network Node setup. You may have one that's missing. Also check out the Devices and User Workstation|Peripheral setups. They're probably all stemming from that missing com port record.