I'd rather read last line from .database to get its last registered number
if .database is empty,or doesn't exist num
let's say .database looks like this :
i'd get last num like this:
IFS=$'\t' read num nm <(tail -1 ~/.database)
and send data in like this:
printf '%s\t%s\t%s\t%s\n' $num "$name" "$relation" "$phone" >> ~/.database
aside, you'd better not use uppercase variable names (even for readibility), it's reserved for environmental variables, by convention.