Police officers, sheriff’s deputies and others were using the database to check the photos and other personal details of TV personalities, politicians and others, sometimes to see whether someone had gained weight since their last renewal.