Subject Re: complex indexes vs index key fields
From Mervyn Bick <invalid@invalid.invalid>
Date Sun, 2 Aug 2020 23:08:22 +0200
Newsgroups dbase.getting-started

On 2020-08-02 21:53, Gaetano wrote:
>

> "followed up" from Thunderbird ;)
> (I used "reply" the first time but that didn't have the expected result...)

In Thunderbird, "Reply" is for emails, "Follow up" is for NNTP messages.


>>> All tables MUST have a primary key otherwise you won't be able to
>>> UPDATE or DELETE specific records.  This is often an autoinc type
>>> field but it can, in fact, consist of multiple fields.  For instance,
>>> the primary key for your energydata could be a combination of siteId
>>> and eTimestamp.
>>
>> I prefer autoinc as they do not require any maintenance. SiteID and
>> eTimestamp can serve as a combination but what will be there to
>> prevent accidental duplicates.
>> But I never encountered this kind of situation before hence cannot say.

By setting PRIMARY KEY (siteID,eTimestamp) the combination of the
contents of the two fields is the key.  You will only be able to use a
specific timestamp once for each siteID.  There can't be any duplicate
timestamps for a siteID.

Mervyn.