DEV Community

[Comment from a deleted post]
Collapse
 
dealloc profile image
Wannes Gennar

I highly recommend learning at least the basics of designing a database.
Even as a developer it's very useful to know how to model data effectively, and it helps you getting into more 'advanced' subjects like indexing and performance.

How would you even go about developing the data layer in Laravel without knowing how to model a database?

Collapse
 
jsxsudan profile image
Sudan Ghimire

I have designed this. take a look at this and suggest more ideas please..

Collapse
 
dealloc profile image
Wannes Gennar

At first glance:

  • I don't think I understand 100% what you mean with the items like "price -on_sale -sale_price -published_at -edition -isbn"
  • When you're representing money in your applications you must be very careful not to make rounding mistakes (see martinfowler.com/eaaCatalog/money.... and twitter.com/billkarwin/status/3475... unless you want to end up losing money
  • orders also require special attention. When making references to users for example you have to keep in mind that if a user deletes his account, you may still need to keep the orders (for financial / legal reasons), and you might have lost required data since the user the user_id field refers to no longer exists.
  • You keep the total price in the order entity, why is it duplicated in the create_book_order_table?
Collapse
 
jsxsudan profile image
Sudan Ghimire

Media

  • id
  • name
  • path
  • type

User

  • id
  • name
  • email
  • password
  • role -media_id

Category

  • id
  • name
  • category_id

Author

  • id
  • name
  • description

Book

  • id
  • title
  • price -on_sale -sale_price -published_at -edition -isbn
  • description
  • media_id

table: create_author_book_table

  • author_id
  • book_id

table: create_book_category_table

  • book_id
  • category_id

Review

  • id
  • book_id
  • user_id
  • rating (int: 1 to 5 stars)
  • message

Order

  • id
  • user_id
  • total_price
  • discount
  • delivery_address
  • billing_address
  • remarks
  • status (Pending, Confirmed, Delivered, Refund)

table: create_book_order_table

  • book_id
  • order_id
  • quantity
  • price