0

I plan to create an application for iOS using Core Data, which will help my client in managing their designed clothes. I'm thinking about the database structure and I'm a little bit confused because, I don't know if my structure will be enough for the planned data operations. If it is not a big deal for you, please take a look at my database date model that I create by using Xcode. Maybe if I tell you about my planned queries you would understand my date model schema more easily.

Relationships:

1 Product --- Category (one to one) example

{
name: "Black Modern Jacket"
price: 200
image: photo.png
category : {
            category_id : "1234",
            name : "updated name"
         }
sizes:(id),
history:(id)
}

2 Category --- Sizes (one to many)

{
name: "Jackets"
sizes : [
         {
            australia : "XXL",
            europe : "52/54",
            japan : "XXL",
            uk : "XXL",
            usa : "XXL",

         },
         {
            australia : "XL",
            europe : "50/52",
            japan : "XL",
            uk : "XL",
            usa : "XL",

         }       
        ]
}

This one relationship I want to use to populate custom UIPickerViews during add packageItems, for example, if the product is a type of jacket, I will display sizes from XXL - XS. If the product is a type of shoes, I will display sizes like 7.5, 8.0, 8.5, 9.0 and so on.

3 Package --- PackageItem (one to many) "Package nr 12/2013 created in 12.12.2013 has many packageItems

{
packageNumber: "12/2013"
creationDate : 12/12/2013
notes : @"additional notes"
packageItems: [
        {
          quantity : 12,
          product : "Black Modern Jacket"(productId==1293)
         sizes: [
        {
          sizeName : "XXL",
          quantity : 6,
        },
        {
          sizeName : "XL",
          quantity : 2,
        },
        {
          sizeName : "L",
          quantity : 7,
        },           
      ]
}

}

4 PackageItem --- Product (one to one)

5 PackageItem --- ItemSize (one to many)

{
product : "Black Modern Jacket"(productId==1293)
package : "12/2013" (packageId) = 1213
itemsizes: [
        {
          sizeName : "XXL",
          quantity : 6,
        },
        {
          sizeName : "XL",
          quantity : 2,
        },
        {
          sizeName : "L",
          quantity : 7,
        },           
      ]
}

6 PackageItem --- ItemHistory

 {
product : "Black Modern Jacket"(productId==1293)
package : "12/2013" (packageId) = 1213
itemsizes: [
        {
          sizeName : "XXL",
          quantity : 6,
        },
        {
          sizeName : "XL",
          quantity : 2,
        },
        {
          sizeName : "L",
          quantity : 7,
        },           
      ]
}

7 Product --- Product Size (one to many)

{
name: "Black Modern Jacket"
price: 200
image: photo.png
sizes :  [
        {
          sizeName : "XXL",
          quantity : 6,
        },
        {
          sizeName : "XL",
          quantity : 2,
        },
        {
          sizeName : "L",
          quantity : 7,
        }],
category: (id)
history:(id)

}

8 Product --- Product History (one to many)

    {
name: "Black Modern Jacket"
price: 200
image: photo.png
history :  [
        {
          dateOfChange: 12/12/2013,
          purposeOfChange: "deliver to: (reseller name) in package nr. 12/2013" ,
          changedValue : "XXL - 1, XL - 5, L - 9, M - 3, S - 3 , XS- 0"
        }],
category: (id)
sizes:(id)

}

The below list shows some basic functionalities of my app

1 define new product, edit product, delete product, display availability of product in every resellers magazine,

2 define new reseller store, edit reseller, delete reseller, display available number of sizes in reseller magazine, edit number of sizes in reseller magazine, show history of product in reseller magazine (changed number of sizes, with date and purpose of this change)

3 create package, edit package, delete package

Moreover I plan to use stack mob baas solution to store my client's data

Please take a look at my dateModel and if you see some errors just let me know. Thanks in advance.

My dataModel schema in Xcode

auspicious99
  • 3,902
  • 1
  • 44
  • 58
sonoDamiano
  • 185
  • 1
  • 12

1 Answers1

0

You know the domain area so you have the best ability to judge. To me there is a lot of duplication in your data model (size and product) but it may be required for subtle differences.

The main issue I see is unique identifiers so that you can find the appropriate objects to update when you receive changes from the server. Your data seems to contain some identifiers, though not in all the places I would expect (this could just have been omitted for brevity). And your data model doesn't seem to store any identifiers.

I'd say there are some multiplicity issues too. Can a Category really only have 1 Product?

Wain
  • 118,658
  • 15
  • 128
  • 151