Post by jrr » Tue Mar 16, 2021 12:44 pm

I was rummaging around the DB just looking it over as I'd had some trouble with searches when I found that oc_product_description had two primary keys!

These are found in product_id and language_id when one looks at the structure under phpMyAdmin. Note I am running php 7.3.x, and my collation is utf8mb4_unicode_ci.

I understood that two primary keys was not supposed to exist in a DB so I tried a totally fresh locahost install and yup, there it is again in oc_product_description.

I haven't turned up any reference to this in a few searches so I figured I'd post it here. Everythign I see says you can't have two primary keys in one table so either phpMyAdmin is reporting some other key for language_id as a second primary key or OC has a slight issue here...

I now see there are many tables with two or more primary keys. I thought using more than one primary key in a table was a bad idea but perhaps I am reading the wrong information. Can someone enlighten me please?

Thanks!
Last edited by jrr on Wed Mar 17, 2021 12:49 am, edited 1 time in total.

jrr
Active Member

Posts

Joined
Mon Nov 20, 2017 1:48 pm

Post by kestas » Tue Mar 16, 2021 5:04 pm

You can have multiple primary keys. They will enforce unique values, and will speed up querying of those values. https://stackoverflow.com/questions/217 ... ate%20keys.

Custom OpenCart modules and solutions. You can write PM with additional questions... Extensions you can find here


Active Member

Posts

Joined
Tue Oct 12, 2010 2:23 am

Post by JNeuhoff » Tue Mar 16, 2021 6:58 pm

It's correct. Its primary key consists of 2 indexes to make it unique: product_id and language_id

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am

Who is online

Users browsing this forum: No registered users and 102 guests