I have two database structure:
#1: Each book is a row:
// sale +----+---------+-------------+ | id | book_id | customer_id | +----+---------+-------------+ | 1 | 5 | 123 | | 2 | 5 | 123 | | 3 | 9 | 123 | | 4 | 4 | 456 | | 5 | 12 | 456 | +----+---------+-------------+
#2: There is a number column:
// sale +----+---------+-------------+--------+ | id | book_id | customer_id | number | +----+---------+-------------+--------+ | 1 | 5 | 123 | 2 | | 2 | 9 | 123 | 1 | | 3 | 4 | 456 | 1 | | 4 | 12 | 456 | 1 | +----+---------+-------------+--------+
As you can see, the first one has a different existence for each book (which would be good for some ideas in the future, i.e returned books which need returned date, or giving some discounts on the multiple procurement of the same book or whatever). But the second one seems more optimal, since it has fewer rows.
Anyway, which one is your recommendation? I personally like the first one and I’m just worried about the redundancy. Has the first structure redundancy?