I would like to understand what OLTP is

Asked

Viewed 1,038 times

1

They asked me this question: What is OLTP? I ran home, opened google and started to "goolgar", so I came across these codes, who say they have problems in OLTP environments and I’m not understanding bulhufas:

public JsonResult ListarAlocacoes(AlocacaoView alocacaoView)
{
    var contratosAlocacaoList = ObterContratosAlocacao(alocacaoView);

    /* ... */
}

private IList<AlocacaoJson> ObterContratosAlocacao(AlocacaoView alocacaoView = null)
{
    var contratoList = BaseContext.DbContext.Set<Contrato>().Include("ContratoValores").ToList();

    foreach (var contrato in contratoList.Where( /* ... */ ))
    {
        var alocacao = MontarAlocacao(contrato, alocacaoView.CompetenciaId);

        /* ... */
    }

    /* ... */
}

private AlocacaoJson MontarAlocacao(Contrato contrato, DateTime dataCompetencia, int? equipeId = null)
{
    var alocacao = new AlocacaoJson();

    /* ... */

    alocacao.Equipe = ObterEquipeContrato(contrato, equipeId);
    alocacao.CustoTotal = ObterCustoTotalContrato(contrato, dataCompetencia);

    /* ... */
}

private EquipeJson ObterEquipeContrato(Contrato contrato, int? equipeId)
{
    var equipe = BaseContext.DbContext.Set<Equipe>().Find(equipeId.Value);

    /* ... */
}

private CustoTotalJson ObterCustoTotalContrato(Contrato contrato, DateTime dataCompetencia)
{
    var competencia = BaseContext.DbContext.Set<Competencia>().Where(c => c.Data == dataCompetencia).First(); ;
    var alocacao = BaseContext.DbContext.Set<Alocacao>().Include("AlocacoesProjeto").Include("Contrato").Include("Equipe").SingleOrDefault(c => c.CompetenciaData == competencia.Data);

    var valorHora = BaseContext.DbContext.Set<Funcao>().Find( /* ... */ ).ValoresHoras.SingleOrDefault( /* ... */ );

    var custoTotal = (decimal)(valorHora.Valor * alocacao.QtdeHoras) /* ... */;

    /* ... */
}

In a production environment, would that support an OLTP approach? Why?

  • You may have seen, but I leave no reference: https://social.technet.microsoft.com/wiki/contents/articles/6934.oltp-x-olap-pt-br.aspx

  • 2

    The OLTP term is most associated with database design, the main features of the systems (most) that adopt this approach are standard tables/entities and transaction orientation. Another model is the OLAP used in Dataware Houses its focus is on reading data so it is less normalized than OLTP.

  • 1

    If I understand correctly, if no transactions are used in the database, the above code can produce inconsistent results.

  • Did the answer resolve what was in doubt? Do you need something else to be improved? Do you think it is possible to accept it now?

1 answer

4

There are basically two models of access/data processing in the database, the OLTP (Online Transaction Processing) and the OLAP (Online Analytical Processing).

OLTP is what almost everyone does, registers, alters, changes some specific point of a data, removes, calculates, recovers to view or access directly, does some batch processing to change the data in general. It’s the data of the day.

OLAP is used in data analysis, in general a large volume and together. The data does not usually need to be the most current, it is common to take what was generated in OLTP and copied to work with OLAP. It is common that in OLAP new data is generated based on what came from OLTP. It can come from several sources, not necessarily a database. This is usually called Data Warehouse.

Any code can have problems in OLTP or OLAP if it is not well done. Just looking at the code does not know. Who said this said why? Did you talk about what situation? What data volume? What is the level of effective competition? Showed other relevant points of the code and general structure?

If you don’t have any of that information, you can’t be trusted. Always remember that there are many people writing things on the Internet, and most of them are wrong, incomplete, inaccurate or biased.

It may be the lack of correct transaction, but I do not know, when it has too much abstraction becomes more complicated to affirm. It is possible, but does it need this transaction? It is possible.

There are even several myths about the subject in articles that even seem reliable. But that’s another subject.

Browser other questions tagged

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