implemented cart and history to improve DB access complexity