N
N
Noin2017-06-06 17:35:53
Java
Noin, 2017-06-06 17:35:53

How to organize the storage of a list of objects in the database?

Hello!
The task is to map a certain object in the database (let's call it Sklad) and issue it by REST request. And everything would be fine, but there is an unpleasant moment in all this - the desired object contains an array of other objects (let's call it Good) and a certain number that corresponds to the quantity.
Those. there is a certain dictionary in the database (it maps to the TovarDictionary object), Tovar expands it with a certain number (quantity). And the array of these Goods must be stored in the desired Sklad object, and there are already 7 such objects as Goods. In JAVA it's like this:

public class Sklad {

    private long id;
    private String name;
    private List<Tovar> vars;
    private List<Tovar1> vars1;
    private List<Tovar2> vars2;
    private List<Tovar3> vars3;
    private List<Tovar4> vars4;
}

public class Tovar extends С {

     private count
}

public class TovarDictionary {
 
    private long id;
    private String name;
    private String descr;
}

Here's how to shove all this canoe into the database? What is better to use? Can generally hit noSQL?
The most obvious option is to create a bunch of auxiliary tables, with the help of which everything will be mapped. But it seems to me that there is a more beautiful solution, which the whole world knows about, except for me ... So far, the most interesting option is to use PostgreSQL with its goodies in the form of custom types and arrays

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question