When to put payments into your own SQL table?

I have a system where users post data and they can update their post with an extra charge to update. This is the information I want to save from the strip in response to their payment:

CREATE TABLE IF NOT EXISTS `db`.`pay` (
  `payments_id` int(11) NOT NULL AUTO_INCREMENT
   payment, unique index',
  `stripe_id`
  `card_id`
  `brand`
  `amount`
  `created`
  `currency`
  `paid`
  `refunded`
  `exp_month`
  `exp_year`
  `last4`
  `country`
  `fingerprint`
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='payments';

      

If it will be in the same table as the one that contains the main message data, or should be a separate and linked table. What logic is used to make this decision?

On the one hand it seems nice to separate it, but then you also have the overhead of binding tables. Only one payment will be associated with one message.

+3


source to share


1 answer


The card data must be in another table with a user id that refers to your custom table.

With limited knowledge of what you are trying to achieve, I would say you need at least 3 tables.



  • Users table
  • Post Table with userId binding to user table
  • Payment card table with userId linked to user table
+2


source







All Articles