In abandoning his plan to use the census to collect information on citizenship, Mr. Trump directed federal agencies to mine their databases for citizenship data. Across the country, law enforcement agencies have connected to databases that are not under their jurisdiction. ICE officers routinely had access to a database of license plates run by the Washington State Department of Licensing. In Massachusetts, state police ran thousands of searches through the state’s prescription data monitoring program, which contains millions of sensitive records on people’s prescription histories.

[If you’re online — and, well, you are — chances are someone is using your information. We’ll tell you what you can do about it. Sign up for our limited-run newsletter.]

All of this has to stop, if the government is to be trusted with citizens’ data. We need legislation that restricts agencies’ access to data for reasons other than the purpose for which it was collected. Since 2018, Massachusetts, along with 12 other states, has restricted access to patient data, requiring law enforcement to obtain a warrant in order to retrieve it. Similar laws need to be passed for all identifiable data existing in government data sets. If an agency needs access to data, it should have to obtain a warrant.

Resources should be devoted to ensuring that ordinary people know how to download data sets for their own research and curiosity. Already, community organizers and activists have used data to hold government agencies accountable. Mijente, a Latinx-led immigrant rights group, has used multiple Freedom of Information Act requests to reveal the details behind high-profile ICE raids.

In addition, agencies should make it easier for people to know when someone else has viewed their records.

Finally, researchers and those tasked with collecting data need to think like the advocates who were successful in defeating the Trump administration’s attempts to add a citizenship question to the census, and ask themselves if the data they are collecting will put the people at risk. Is the potential harm caused by asking a question greater than its research value? Sometimes, the answer will be yes.

By providing a picture of Americans’ experiences, data collection can in fact serve the public good — but only if the people who provide the data are treated with the respect they deserve.

Abdullah Shihipar is a masters of public health candidate at Brown University’s School of Public Health.

Like other media companies, The Times collects data on its visitors when they read stories like this one. For more detail please see our privacy policy and our publisher's description of The Times's practices and continued steps to increase transparency and protections.

Follow @privacyproject on Twitter and The New York Times Opinion Section on Facebook and Instagram.