Answer the question
In order to leave comments, you need to log in
Which of the ways to organize the storage of addresses and passport data should you choose?
Good day, dear users.
The question arose of how to organize the storage of addresses and passport users in the database.
At the moment, the addresses are stored as an array and are written to the json field in the database all at once
addresses: {
isAddressSimilar: false, //Адрес регистрации совпадает с адресом проживания
isAddressPlaceOfStay: false, //Адрес регистрации совпадает с адресом регистрации по месту пребывания
registration: {//Адрес регистрации
area: null,
city: null,
index: null,
region: null,
street: null,
housing: null,
settlement: null,
house_number: null,
apartment_number: null
},
residential: {//Адрес проживания
area: null,
city: null,
index: null,
region: null,
street: null,
housing: null,
settlement: null,
house_number: null,
apartment_number: null
},
place_of_stay: {//Адрес регистрации по месту пребывания
area: null,
city: null,
index: null,
region: null,
street: null,
housing: null,
settlement: null,
house_number: null,
apartment_number: null
},
},
passport: {
nationality: 'russia',
documentType: 'RfPassport',
series: null,
number: null,
issuanceDate: DateTime.local().toISODate(),
subdivisionCode: null,
issued: null,
birthPlace: null,
},
Answer the question
In order to leave comments, you need to log in
Most likely, the type of storage depends entirely on several factors:
In my opinion, in view of the foregoing, this type of information should be broken up into small pieces and put into separate tablets. And let the preachers of the doom of relational models laugh at me - I'm a stubborn conservative.
Pavel Chesnokov speaks the matter, but in fact:
- User hasOne Passport / Passport belongsTo User (OneToOne connection)
Addresses are a bit more complicated, here I would store the addresses themselves separately through the OneToMany connection, with an additional type property. But isAddressSimilar and isAddressPlaceOfStay are either flags in the User, or a dynamic property in general - for example, if there is no address entry with the place_of_stay type, then we use the default (registration) or simply return false. For to store records where all columns except PK null it not apprx.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question