yes, some time both are necessary.
php validation and database validation.
let's have a simple situation.
if we don't assign a primary key or unique key,
then if , somehow, (intended) user by pass php code validation then database will have same records twice.
but if we assign a primary key then it would be not possible.
It is always but according to need.
let's simply explain.
the final important thing is your database , like a vault.
Now you have to decide it where to put it in a house. means after how many gates should be there to access that vault.
like if you have less important things then you will not need to worry about them , but for most important things, like cash, gold etc, you will always put it in secure and more authenticated place.
So it basically depends upon needs.
In application like, accounting,erp, etc you will always try put a constraint(database validation) b/w columns so that error chances b/w balance would be very low.