Database design shortcoming?...or not?

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Database design shortcoming?...or not?

Post by igavemybest » Tue Apr 13, 2010 11:52 pm

I have a question, and since I am not a database guy maybe someone more skilled could answer this for me.

When doing custom imports, etc... if someone adds a product in the database they must create a corresponding row in ac_CatalogNodes. But when someone wants to delete a product they must remember about the record in ac_CatalogNodes to delete it too. Same with categories. Why isnt this done with foreign keys, and then records from ac_CatalogNodes deleted automatically.

One more example. ac_CategoryParents does not have foreign key for ParentId, so I can write 938293482039482 in this column and there is no category with this ID.

Just trying to understand the reasoning, to better understand the functionality. Any help is appreciated :)
Last edited by igavemybest on Thu Apr 15, 2010 4:50 pm, edited 1 time in total.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Database design shortcoming?...or not?

Post by mazhar » Wed Apr 14, 2010 6:57 am

In software solution some time to you may need to make some decisions to make deviations to standard rules in order to achieve flexibility. ac_CatalogNodes is a special table and every entry of catalog node table represents a catalog object. There could be four different catalog objects categories, products, webpages and links. So every entry in there is associated to one for the four tables. You can't enforce constraints because you can't map four foreign keys on on column CatalogNodeId. Its will be the code responsibility to make sure to enforce this kind of constraints. If you are using AbleCommerce API then you don't need to worry about this. It will handle it automatically.

User avatar
igavemybest
Captain (CAPT)
Captain (CAPT)
Posts: 388
Joined: Sun Apr 06, 2008 5:47 pm

Re: Database design shortcoming?...or not?

Post by igavemybest » Wed Apr 14, 2010 12:29 pm

Ahhh..ok. Makes sence. Thanks for the insight :)

victor_k
Ensign (ENS)
Ensign (ENS)
Posts: 1
Joined: Thu Apr 15, 2010 2:10 am

Re: Database design shortcoming?...or not?

Post by victor_k » Thu Apr 15, 2010 2:16 am

But there are other solutions. For example you can create one column for each object type (categories, products, webpages and links) and create corresponding foreign keys for each column. Then, if you want to work with one column you can crate additional view with current ac_CatalogNodes structure. This way can be even fast. Code should not be held responsible for the consistency of the database.

And what about ParentId in ac_Categories?

Regards.

User avatar
Logan Rhodehamel
Developer
Developer
Posts: 4116
Joined: Wed Dec 10, 2003 5:26 pm

Re: Database design shortcoming?...or not?

Post by Logan Rhodehamel » Wed Apr 28, 2010 3:29 pm

igavemybest wrote:One more example. ac_CategoryParents does not have foreign key for ParentId, so I can write 938293482039482 in this column and there is no category with this ID.
That is not a normalized table. It is a custom index that is necessary to support certain features within the product, especially ones that involve inheritance of categories.
Cheers,
Logan
Image.com

If I do not respond to an unsolicited private message, it's not because I'm ignoring you. It's because the answer to your question is valuable to others. Try the new topic button.

Post Reply