People often say of the Liberal Democrats: what are they there for?

Actually, they've been saying much nastier things about the LibDems since their leader, Nick Clegg, reneged on his pledge not to raise university tuition fees after entering coalition with the Tories in 2010.

But broken promises aside, I think now we have an answer to what the LibDems are for: they're the only major party, Greens aside, that really takes issues of civil liberties seriously, as we saw yesterday with their debate on the Scottish Government's plans effectively to create a national identity database.

Leader Willie Rennie's motion to stop the measure being rushed through without proper parliamentary scrutiny succeeded by 65 votes to 60 in the Scottish Parliament after an intelligent and thoughtful debate; a rare occasion on which Deputy First Minister John Swinney was sent back to think again.

We need parties that keep a vigilant eye on government. Labour has never quite got this privacy thing having been, for most of its existence, a party very much of and for the big state. The Tories are supposed to be the party of the individual but their law'n'order populism, hostility to immigration and preoccupation with state security have made them suckers for any agency - police, spooks, tax authorities and so on - that wants to snoop into our affairs.

The Tories seem to recognise threats to civil liberties when in opposition. Their spokeswoman Liz Smith MSP is opposing the latest plans from the Scottish Government as "identity cards by the back door".

The SNP are similarly schizophrenic. They opposed the introduction of a national identity database in 2005 when it was proposed by Tony Blair's Labour government. But once the Nationalists got into government they started succumbing to the same pressures to tighten up all round and, of course, to praise our wonderful police, as Nicola Sturgeon did last week.

The SNP's conversion to the construction of what is effectively a Scottish ID database is typical of what happens to well meaning political parties when they find themselves in government. Ministers start spending much of their time with civil servants, quangocrats and people in authority who all seem to think they just can't get their jobs done without poking their noses further into our private affairs.

There are a hundred reasons for doing this and a thousand ways to erode civil liberty, and most of them seem perfectly reasonable. Why allow people to avoid tax, or evade the police? Or, indeed, fail to be informed about certain benefits to which they could be entitled?

The NHS already has a record of everyone who has been born and died, so what's the problem? There are lots of different public bodies that collect data on citizens. So why not throw this open to all 120 to avoid duplication? Why should lots of other organisations compile separate lists of who is entitled to what?

Why not give everyone a Unique Personal Reference Number based on the NHS register then make it compulsory, so we know who is whom? Then, maybe, people could use those nice National Entitlement Cards to ensure they get what they are due? All perfectly reasonable until you realise that this is, in essence, the UK identity card system that was scrapped in 2010.

You can well understand why the SNP are worried about tax avoidance. With the Smith reforms heading over the horizon giving Holyrood powers over income tax, the Government is anxious to ensure that every penny is collected. To do this, it has to know who we are, where we are and to whom we are supposed to be paying our taxes.

John Swinney's insistence that "no new database is being created" is disingenuous, since of course it is the integration of existing databases that is objectionable. They are more than the sum of their parts. The Scottish Government seems to be arguing that this is all okay in Scotland because they will be in charge of the database and they are good people.

But organisations ranging from the BMA to the Scottish Council for Voluntary Organisations are backing the Open Rights Group's campaign against this measure. This isn't a party political issue, still less a constitutional one, and Yessers should beware backing intrusive and ill-considered legislation just because it has an SNP stamp on it.

Perhaps the most worrying aspect is that the ID will be based on the NHS, possibly the least competent user of information technology in history. It blew £12 billion on a computerised records system that didn't work. You don't have to be paranoid to start worrying about going into hospital for a hernia and emerging on some sex-abuse register.

The increase in official intrusion into our personal lives is one of the legal mega-trends of the 21st century. The introduction of "named persons", Claire's laws, disclosure checks and barred lists is creating a nether world of partial and unreliable information on all of us. Pretty soon it will be illegal not to record any and every rumour of abuse or paedophilia about people in the workplace.

At some point all this is going to collapse into one massive database of various classes of information all cross-referenced and much of it unknown to us: an incredibly powerful tool to put in the hands of the state. And no, that is not what the Scottish Government is proposing with its Unique Personal Reference Number. But it is hard to see it as other than a step further down the road.

Power corrupts and knowledge, or rather access to it, is power in the digital age. The fact that officials and government ministers can't understand the dangers of effectively creating a personal identity register is precisely the reason we need strong political opposition and parliamentary accountability.

With computers compiling ever larger databases, it is becoming harder than ever to defend the principle of personal privacy. Indeed, the idea of opposing an identity database seems positively anachronistic in the age of mass surveillance. Edward Snowden's revelations about programmes like Prism that hoover up all our personal information on the internet have led most of us to assume that the police and spooks know all they want to know about us already

Police and victims groups will forever insist that civil liberty is a luxury we cannot afford in the fight against organised child abuse and acts of murder by ISIS. If one child is saved ... if one terrorist atrocity is avoided, then surely the price is right; except that it isn't. Some things are more important, and personal freedom from arbitrary authority is one of them.

Officialdom's demand for information and control of our lives is insatiable. Only the LibDems seem to understand this, which is why they have scored a major victory for parliamentary scrutiny. They are absolutely right to hold the Scottish Government to account and demand that this should be a matter for primary legislation after a national debate on the implications for personal liberty. All power to Willie Rennie, even if he is fighting what looks increasingly like a losing battle.