Do not store dots at all. Just make inquiries on this view. Thus, it will be sustainable in the face of arbitrary change.
create view UserPoints
as
select
created_by_id as user_id,
'STORE' as action_type,
store_id as action_id,
(select points from action_points where action_desc='create store') as points
from store
union
select
user_id,
'ANSWER' as action_type,
question_id as action_id,
(select points from action_points where action_desc='answer question') as points
from answer
union
select
referred_by_id as user_id,
'REFERRAL' as action_type,
referred_id as action_id,
(select points from action_points where action_desc='referral') as points
from referral
Edited to add:
. : .
, . . , , . , , , , . , - . , .
, .
, , , , .
user_id action_type . , , !
select
sum(up.points) as total_points,
up.user_id,
u.user_name
from
UserPoints up
join user u on up.user_id = u.user_id
group by
user_id,
user_name
order by
total_points desc