⊗jsrxPmSDDM 39 of 57 menu

Creating Database Data Models in Redux

In this lesson we will populate the data models we created in the last lesson.

Let's open our product app, and in it the file server.js. Let's start with the product model. The data we will receive for it is the name, description, price, quantity, reactions and seller of this product. Let's enter these necessary properties with their value types, as well as the relationships between the models into an object - just like in a real database. As you noticed, the field values ​​for the reaction and seller are associated with the corresponding models:

product: { id: primaryKey(nanoid), name: String, desc: String, price: Number, amount: Number, reactions: oneOf('reaction'), seller: oneOf('seller'), },

Let's move on to the data model for the seller. Here we need data on the name and products that this seller has posted (we take the value from the product model. One seller may have several products):

seller: { id: primaryKey(nanoid), name: String, products: manyOf('product'), },

And finally, a model for reactions. Our reaction can be 'good', 'neither fish nor fowl' and 'bad'. It also applies to some product. Let's write it like this:

reaction: { id: primaryKey(nanoid), good: Number, soso: Number, bad: Number, product: oneOf('product'), },

Our database model is ready!

Open your app with students. After reviewing this lesson, fill out your three data model templates student, teacher, and vote with the necessary properties, value types, and relationships.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline