On 20.06.2022 10:23, andy pugh wrote:
> On Sun, 19 Jun 2022 at 08:35, Håvard F. Aasen via Emc-developers
> <emc-developers@lists.sourceforge.net> wrote:
> 
>> As this is described, it seems to me that toolID really is a description,
>> and T_number could be used as the primary key, like so
>>         toolID          INTEGER PRIMARY KEY, -- alias T_number
>>         description     TEXT
>> Does this suggestion has any unintended side effect? Not completely sure
>> the reasoning behind the original table layout.
> 
> You have to bear in mind how the tools are called up from the G-code.
> 
> M6 T6
> 
> There is only a single integer passed to whatever selects the tool.
> And if T6 is a 6mm square ended milling cutter (for example) it is
> quite likely that you don't care _which_ 6mm square ended cutter you
> get.
> 
> You would generally be perfectly happy to get the nearest, the least
> worn, the one actually in the active carousel, or one chosen by some
> other criterion.
> 
For some reason I have been hung up with the toolID field and thought
that it would be the field to search for, I guess we would actually
search in the t_number attribute and the search query would be something
like
SELECT * FROM tool WHERE t_number = 6;

and it will return 0, 1 or many results, and the code or library would
choose which one to use, if many.

> So, the tool _number_ as associated with the G-code T-command is very
> deliberately _not_ a key but a "property."
> 
Makes sense, but then I hope you will consider Rob and Jérémie suggestions,
with auto incremented primary key, name and description field.

Something like this


CREATE TABLE tool
(
    toolID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
    geom_groupID INTEGER NULL DEFAULT NULL,
    name TEXT NULL,
    description TEXT NULL,
    t_number INTEGER NOT NULL,
    spindle_hrs REAL NOT NULL DEFAULT 0.0,
    distance REAL NOT NULL DEFAULT 0.0,
    in_use INTEGER NOT NULL DEFAULT 1,
    max_rpm INTEGER NOT NULL DEFAULT -1
);

This also changes geom -> geom_groupID to make it easier to see that it's a
foreign key with geom_group table.

Personally I find it a bit excessive to append the table name before
the attributes.


_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to