Installment for mysql

Asked

Viewed 304 times

0

I am making a sales system in which 1 sale generates 12 installments for 3 users, being the seller, the manager and the supervisor, I would like to know the best method for storing these installments.

It would create 1 table for each user and when making the sale generate the 36 rows, a cronjob which would generate the instalments each month or so?

It is a system for about 100 users.

  • 1

    It is a little confused, can explain better? After all, it is 12 installments or 36? Anyway, creating a table per user is a bad idea, create a table only with a column indicating which is the user.

  • @bfavaretto are 3 types of users being them (seller, manager and supervisor) each sale generates 12 installments for each 1 of them with different values. for example: 1 seller makes a sale, from this sale 1.7% is the seller’s commission, 0.3% is the supervisor’s commission and 1.5 is the manager’s commission. and if this sale is by indication of some customer has more customer’s commission

  • @Kelvinprimo this is two different things, user type has to be a table "type" with id in user table: tipo_id or so. after each user id has to be in the sales table: usuario_id

1 answer

0


It does not need very far. In case you can use 3 simple tables, as see in this very pig ER diagram that I just made.

inserir a descrição da imagem aqui

  • then, this idea was what I was trying to avoid, because in 1 year in the best chances would already have 360000 Rows the commissioning table. among them the defaulting.

  • So far so good. Mysql gives no problem of this number of records. What you could do there is to create 2 views. One for parcel houses and one for defaulters if you want an easy way to separate them.

  • If you follow this template you can also partition Tablea. Here is an example of how to do this: http://www.w3resource.com/mysql/mysql-partition.php With it makes logical and physical separations of the records, according to the way you want to model (year by example).

  • I had the following idea a little bit, I would like your opinion, when the user confirms the payment of the 1 installment, the system would generate the second. and this successively.

  • I get it, you want to generate as it is paid. It works, but would make it difficult at the time you for example need to look for defaulters for example. But it all depends on the operations you intend to perform. But remember the number of records in the table is not important as long as you use correctly indices and Chavs. Usually tables that tend to grow a lot, I also avoid using INT or BIGINT as the primary key, preferring a GUID.

  • huum, got it. I’ll take your advice and in case the bank gets too big you have to leave for partition. thank you very much.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.