Help with adding transaction tracking data

The php video web script that I’m trying to modify has a process where Users generate credit units from viewed videos.
The total ‘balance’ of credits is stored in mysql db table named 'User', in a column titled “balance”, with each total reflected in a users’ row, and the 'balance' total gets updated (goes up or down), depending on the activity of the credits.

However, if 2 credits get added to the balance, for example, there is no tracking of what type of activity caused the balance total…

Help with adding transaction tracking data

Extending fiat transaction log to support cryptocurrency

Assuming that i have an existing database that store fiat currency transaction as follow with decimal (18, 4).

Now I would like to support storing of bitcoin, ethereum and erc20 token transaction.

Transaction ------------------ TransactionID CurrencyID UserID DebitAmount  decimal(18, 4) CreditAmount decimal(18, 4) 

The decimal precision of cryptocurrency suggested as follow.

 decimal (16, 8) - bitcoin  decimal (30, 18) - ethereum / erc20 token 

I am thinking of just:
1) Treating bitcoin, ethereum, erc20 token as new currency in currency table.

2) Changing the DebitAmount and CreditAmount directly to decimal(30, 18)

3) Applying decimal(30, 18) data type changes to all table that store currency amount.

My question is:
1) Any possible impact to original currency amount conversion that i need to look after for when i increase the precision? (eg: currency rate change DebitAmount * 1.023)

2) Am i doing this in correct way?

3) Is there any other better approach/alternative to this?

Long running READ queries stuck in “idle in transaction”

I have a JDBC connection pool in a web API that makes frequent requests to the RDS Instance. Each request is for a long running SQL query where PG decides not to use indices because the amount of data to be returned is quite large.

I’m noticing that some of these long running queries are just stuck in state idle in transaction. When look up the pid for these processes in pg_locks table they have 152 rows . With mode AccessShareLock.

The intent for this table is to be never updated — It serves as a point in time table. So I don’t see a need for idle transaction or accesssharelock. Is there I can turn these off so that my queries run faster and aren’t stuck because of AccessShareLock?

Do database actions inside a transaction become slower as the transaction grows?

I have a PostgreSQL database running a transaction. Inside that transaction I process around 160 records from an Excel file. As it runs, I see the processing becomes slower with each record (0.05 secs for the first to 0.20 for the last).

Could this be because of the transaction, or should I like elsewhere?

Que argumentos debe tener la funcion que maneja transaction en laravel 5.8

espero me puedan ayudar, no se como usar la transacción, lo estoy haciendo desde el registerControler que te genera Auth.

La transacción funciona cuando hay un error, como por ejemplo matricula o correo repetido, y la información del formulario nunca llega a la base de datos, el problema es cuando la información si esta toda correcta, me general el siguiente error.

“Cannot use object of type Illuminate\Database\MySqlConnection as array”

Entonces aquí mi problema es que no estoy pasando correctamente los datos, CREO…

Espero me puedan ayudar, gracias.

protected function create(array $  data) {     DB::transaction(function ($  data) {          return usuarios::create([             'matricula' => $  data['matricula'],             'nombres' => $  data['nombres'],             'email' => $  data['email'],             'apellPat' => $  data['apellPat'],             'apellMat' => $  data['apellMat'],             'facultad' => $  data['facultad'],             'areaCono' => RegisterController::buscarArea($  data['facultad']),             'genero' => $  data['genero'],             'tipoUsuario' => 2,             'password' => Hash::make($  data['password']),         ]);     }); } 

How to get all transaction_email ,transaction status from sql query Magento 2

I am trying to get all transactions,transactions_id,transaction_email,transaction status by SQL query. I found the table where all transactions are stored sales_payment_transaction, sales_order_payment and sales_order

So I can easily get all transactions and ‘transactions_id’ but how can I get transaction_email,transaction status

sql query

select spt.transaction_id , spt.txn_id, spt.is_closed , so.customer_email from sales_payment_transaction spt INNER JOIN sales_order so on spt.order_id = so.entity_id; 

Is this right ?

Double Entry accounting – table design and showing a transaction list

There have been a few debates on table design for an accounts system. I’m trying to make a little home finance app to learn some new technologies.

My requirements though, are that a transaction, as presented to a user, can be made up of a few sub transactions. That’s to allow for portions of the transaction to be assigned to different budgets.

I have two ideas – both giving me issues. In the examples below, I have 4 transactions.

  1. I get paid 5K
  2. I pay 50 to nandos for dinner
  3. I pay 20 to FKC for lunch
  4. I pay 10 to Coffee Club, but 5 of that comes from my weekly budget, and 5 comes out of my wifes weekly budget

enter image description here

The first idea, I am currently modelling.

enter image description here

A Transaction is the header table, with common data. (Date, Description). (BudgetId in there is an error, and is being removed)

A Transaction has many transaction lines. Which has the source and destination accounts and amounts, as well as the Budget that it’s assigned to if any.

An account is simply an account. Can be a bank account, a shop… anything that I send money to or get money from.

The major issue I have at the moment with this, is the budget. Looking at transaction 4 – why am I putting the budget in two rows only. Should I be splitting the the MyBank to CoffeeClub as well? and that should be 4 rows?

Another issue: If I show the transaction to the user – I want to show: Paid $ 10 from MyBank to CoffeeClub

But how do I do that? I have 3 rows… how do I know it isn’t “coffee Club paid -5 to MyBank”.

The 2nd option also has it’s issues. The SQL to get a summary line of a transaction, seems tricky. I have no way of really knowing what th ‘primary’account is. For example, I want to find all the transactions for MyBank. In the Cr/Dr version, I’d need to select from TransactionLine where Account = MyBank. Which will give me the amounts an ‘dr/cr’, but … I can’t tell who I paid to, or got money from. That’s on a separate row. So I’d need to find the other row (which is part of the transaction) and work out who the money went to or came from). This seems bad.

How do I produce a line like: enter image description here

Both can be checked easily to see that everything is in balance.

Any advice, ideas and critique would be great. Both ideas seem to work, but it’s the SQL to query the data efficiently for both ideas, that is stumping me.