In the Control Panel, there is a "Rebuild link database" button. How does it work? What operations are carried out during a link database rebuild?
Retrieved from the SDN site
What is the Links Database:
"Sitecore maintains a table named Links in the database specified in the LinkDatabase section of web.config. This table provides a logical links database for all other databases – the links tables in the other databases are empty by default. Data is exposed through the Sitecore.Links.ItemLink class.
No matter how many databases are processed to create the links database, all entries are stored in a single table in the database".
The rebuild process will essentially update those records.
Link DB plays key role in managing references across Sitecore items. In simple words, if you select an item and check Navigate>Links, it shows you all the items that refer to the current item and all the items that the current item refers to.
Generally, links in Link Database get updated using Sitecore.Links.ItemEventHandler class. Following events are handled by Sitecore.Links.ItemEventHandler to update the Link DB: item:deleted (OnItemDeleted method), item:copied, item:saved (OnItemSaved method), item:versionRemoved (OnVersionRemoved method)
During development, need may arise to remove an item used extensively within the content tree (template, rendering or form). In such case, we need to find references to an item programmatically. You will need the link DB to updated to show references correctly, else you may end up with broken links in production. This will require a link DB rebuild.