Subject | Re: [firebird-support] Why PLAN token is not allowed after ORDER BY? - Email found in subject |
---|---|
Author | Kjell Rilbe |
Post date | 2012-06-04T06:53:18Z |
Den 2012-06-03 21:23 skrev Alec Swan såhär:
auto generated identifiers, and make them short enough for Firebird:
One approach that may or may not be suitable, but at least would be
rather easy to implement is the way ECO from www.capableobjects.com does
it. They truncate at maxidentlength - 3 and calculate some kind of hash
on the remaining characters (or the complete identifier?) and appends a
three character representation of that hash, e.g. (real example):
ASP_RoleRolesASP_RoleUMSK
This is for an association from the class ASP_Role to ASP_RoleUser. the
UML role name for the link from ASP_Role to ASP_RoleName has, in the
model, been named "Roles" and in the other direction it's named "User",
which would generate the link table name
"ASP_RoleRolesASP_RoleUserUser", which is not too long, but since we set
the max length to 25 in our app, ECO will truncate at 22 chars (25 - 3)
and add MSK which is the hash.
In most cases, 22 chars is enough to understand what it is, but in some
cases you end up with identifiers that differ only in the has, which is
rather annoying. So, depending on your requirements and preferences,
this scheme may or may not be useful to you. At least it's simple.
Side note: We are forced to set max length shorter than FB's max in our
app, because we use Swedish characters. These are encoded with two bytes
in UTF8, the storage format FB uses for identifiers. Unfortunately, FB
has max 31 BYTES for identifiers, as opposed to 31 CHARACTERS, meaning
that if our identifier contains many Swedish characters, the max
identifier length in characters is reduced (by one character per Swedish
character). To be on the safe side we set the max length to 25.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> On Sun, Jun 3, 2012 at 1:06 PM, Leyne, Sean<Sean@...>wrote:Just as a note to ahyone cosidering prettyfying index names or other
>> Yes, there is a limit to the length of an Firebird index name, but you
>> could come up with an algorithm which would be able to shorten the names as
>> appropriate. For example an compound index of
>> COPY_CLASSIFICATION."CLASSIFICATION_CODE" and
>> COPY_CLASSIFICATION."LABEL_CLASSIFICATION_CODE" could be named
>> "COPY_CLASS.CLASSIF_LABELCLASSIF".
> Sean, you nailed the reason on the head - the FB restriction on index
> names. In fact, on SQL Server we have pretty index names :) Unfortunately,
> we didn't have the resources to spend in prettyfying the index names at the
> time. At this point it's even harder to do this because of upgrade
> scenarios.
auto generated identifiers, and make them short enough for Firebird:
One approach that may or may not be suitable, but at least would be
rather easy to implement is the way ECO from www.capableobjects.com does
it. They truncate at maxidentlength - 3 and calculate some kind of hash
on the remaining characters (or the complete identifier?) and appends a
three character representation of that hash, e.g. (real example):
ASP_RoleRolesASP_RoleUMSK
This is for an association from the class ASP_Role to ASP_RoleUser. the
UML role name for the link from ASP_Role to ASP_RoleName has, in the
model, been named "Roles" and in the other direction it's named "User",
which would generate the link table name
"ASP_RoleRolesASP_RoleUserUser", which is not too long, but since we set
the max length to 25 in our app, ECO will truncate at 22 chars (25 - 3)
and add MSK which is the hash.
In most cases, 22 chars is enough to understand what it is, but in some
cases you end up with identifiers that differ only in the has, which is
rather annoying. So, depending on your requirements and preferences,
this scheme may or may not be useful to you. At least it's simple.
Side note: We are forced to set max length shorter than FB's max in our
app, because we use Swedish characters. These are encoded with two bytes
in UTF8, the storage format FB uses for identifiers. Unfortunately, FB
has max 31 BYTES for identifiers, as opposed to 31 CHARACTERS, meaning
that if our identifier contains many Swedish characters, the max
identifier length in characters is reduced (by one character per Swedish
character). To be on the safe side we set the max length to 25.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64