Thursday, 20 December 2018

[SQL] Efficient update with data from other table

Go along the following template:

  • If you have columns to update from the same table set, use column set updates.
  • Use correlated subqueries for calculation of the values as well as for restriction of the rows to update. There you can employ an exists clause

DB2 is said to be able to recognise that both subselects are identical and therefore won't resolved twice. I suppose any clever database works like this.

update TO_BE_UPDATED U
  set (COL_1, COL_2) = (
         select S.ATT_3, R.ATT_4
           from SOURCE_TABLE S
          inner join RESTRICTING_TABLE R
             on S.KEY_S = R.KEY_R
          where R.SOME_CONDITION between SOME_VALUE and SOME_OTHER_VALUE
            and S.KEY_S = U.KEY_U
      )
where exists (
         select S.ATT_3, R.ATT_4
           from SOURCE_TABLE S
          inner join RESTRICTING_TABLE R
             on S.KEY_S = R.KEY_R
          where R.SOME_CONDITION between SOME_VALUE and SOME_OTHER_VALUE
            and S.KEY_S = U.KEY_U
      )

Tuesday, 18 December 2018

Backdated changes in data history in DWH

Abbreviations

  • DWH: Data Warehouse (probably trivial when you were interested in reading so far 😉)
  • KF: Point in time from when the record is deemed known
  • sKF: smaller VF, i. e. the VF of the record known next earlier to the reference (new) record
  • bKF: bigger VF, i. e. the VF of the record known next later to the reference (new) record
  • KT: Point in time when the record ceases to be valid
  • RP: Reference point in time
  • HP: High-point-in-time, i. e. an arbitrary point in time high enough not to get mixed up in operation, usually the maximum point in time a database can represent. It is a convenience replacement for SQL null value to ease querying.
  • BK: Business key, i. e. not the technical key of this DWH but maybe the technical key of the delivering system or the real identifying key of the business entity. May be composed.
  • DR: Delete record, i. e. a record delivered to make cease the validity of a record of the same BK existing in the target.
  • IR: Insert record, i. e. a record delivered to create valid record (anew)
  • CR: Change record, i. e. a record delivered to create a new version of a record of the same BK existing in the target.

Premises

  • No parallel processing of data or alternatively processing of the data with repeatable read isolation to prevent lost updates.
  • VT is meant exclusively, i. e. the valid-to boundary does not belong the interval defined by VF and VT.
  • As backdated changes are permitted an CR or DR without existing valid

Directions

  • Attribute sKF and bKF (e. g. with lead/lag functions) to the new record
  • Distinguish the following cases:
    • neither sKF nor bKF have been found
      • DR: Into the target insert the new record with KF = RP and KT = RP.
      • IR/CR: Into the target insert the new record with KF = RP and KT = HD.
    • sKF but no bKF has been found
      • DR: In the target update the record of BK with KF = sKF such that KT = RP.
      • IR/CR:
        • In the target update the record of BK with KF = sKF such that KT = RP.
        • Into the target insert the new record with KF = RP and KT = HD.
    • bKF but no sKF has been found
      • DR: Into the target  insert the new record with KF = RP and KT = RP.
      • IR/CR: Into the target  insert the new record with KF = RP and KT = bKF.
    • sKF and bKF have been found
      • DR: In the target update the record of BK with KF = sKF such that KT = RP.
      • IR/CR:
        • In the target update the record of BK with KF = sKF such that KT = RP.
        • Into the target insert the new record with KF = RP and KT = bKF.

Trivia

I very much prefer the term "know" over "valid" as usually the business history of data is built by the primary system and delivered as a payload attribute (opposed to the key attribute(s)). The time axis that the DWH is to build when keeping the history of data is the one of when the characteristics of data of a specific business key gets known by the DWH and when this knowledge gets erased. E. g. at 2001-01-01 a customer registers ergo business validity is from 2001-01-01. This record gets processed and delivered to the DWH at 2001-01-02 ergo the known from is this point in time. The customer thinks twice and quits its business relation ship the next day after registration i. e. at 2001-01-02. This fact gets known by the DWH the next day again i. e. at 2001-01-03.
Delivery 1 at 2001-01-02 to the DWH:

OPERATION VALID_FROM VALID_TO BK EMAIL
Insert 2001-01-01 {null} XYZ foo@b.ar

DWH state at end of 2001-01-02:

KNOWN_FROM KNOWN_TO VALID_FROM VALID_TO BK EMAIL
2001-01-02 {null} 2001-01-01 {null} XYZ foo@b.ar

Delivery 2 at 2001-01-03 to the DWH:

OPERATION VALID_FROM VALID_TO BK EMAIL
Delete 2001-01-01 2001-01-02 XYZ foo@b.ar

DWH state at end of 2001-01-03:

KNOWN_FROM KNOWN_TO VALID_FROM VALID_TO BK EMAIL
2001-01-02 2001-01-03 2001-01-01 {null} XYZ foo@b.ar
2001-01-03 {null} 2001-01-01 2001-01-02 XYZ foo@b.ar

Thursday, 18 October 2018

[Linux] Boot loop after new installation (on Toshiba Portege Z30-a)

UEFI boot stuff is some what sad story. It is said that M$ does not stick to its standard and "BIOS" manufacturers quite often prefere to do this entreprise's bidding. This can lead to problems with non-Windows OS to boot. See also https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface#Criticism. If I remember correctly, Windows overwrites fall back files in EFI/Boot eventhough it has its own directory as all OS are requested to use.
I have run into a problem related to this when Debian Stretch made a system upgrade. A fresh install of it or (l)ubuntu did not remedy.

Symptom

After a system installation or a system upgrade grub does not get loaded. After the manufacturer splash screen a message beginning with "System BootOrder not found." appears for a second or two and the computer reboots.

Cause

The wrong file is at EFI/Boot/bootx64.efi

Solution

Copy EFI/<your operating system>/grubx64.efi to afore mentioned lockation like
sudo mount /dev/sda1 /mnt
sudo cp /mnt/EFI/ubuntu/grubx64.efi /mnt/EFI/Boot/bootx64.efi

Friday, 12 October 2018

[Blogger] Integration of Alex Gorbatshev's syntax highlighter

To integrate Alex Gorbatshev's syntax highlighter you need to add following code to possibly the end of the head tag of the html design template.
<!-- Syntax Highlighter Additions START -->
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeEmacs.css' rel='stylesheet' type='text/css'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushAS3.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushColdFusion.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCSharp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDelphi.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushDiff.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushErlang.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushGroovy.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJavaFX.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPowerShell.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushScala.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/>
<script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
<script language='javascript' type='text/javascript'>  SyntaxHighlighter.config.bloggerMode = true;  SyntaxHighlighter.all(); </script>
<!-- Syntax Highlighter Additions END -->
You can get there as follows.
For its usage see also using-my-configuration-of-alex

Tuesday, 26 June 2018

[TortoiseSVN + PuTTY] Configure public key authentication

  1. Create and save a PuTTY session where you specify the private key file in ppk format (PuTTYgen to convert from openssh format)
  2. Checkout the repository using the PuTTY session name instead of the host name!
  3. Use of PuTTY's plink: TortoiseSVN provides its own flavour plink programm which is the default. You can configure to use PuTTY's original but then you'll get an empty useless command line window which will automagically close on termination of the plink process.

Tuesday, 19 June 2018

Thoughts on graph database

  1. Could one say, that a graph database is a relational database but stores the references as physical addresses instead of logical connections that have to be translated to physical addresses on retrieval? Good for 1:1 but what if 1:n or n:m? Probably not single reference address stored but linked list.
  2. If 1 holds true, is data stored on disk like that or is there a translation between memory and disk?
  3. Are graph databases bidirectional by priciple?
  4. If bidirectional, are there storage penalties?
  5. Performance advantage is especially good with queries involving more than one reference, in relational terms involving more than one join. Maybe this is considered in the spot light of 6
  6. Performance advantage is especially good when starting at one spot and retrieving related data to this spot. For set operations it seems to be the other way round.
  7. Apparently, graph databases store redundant data when they are said to use more storage.
  8. There cannot be, by principle, a link/reference without both ends of the link.
References:

Tuesday, 29 May 2018

[Testlink] (to converted to an insight, for now just a question) Is it possible to use html in the (execution) notes?

Interesting question as line breaks and spaces get condensed. Use instead
bla<br/>blörtz
or
<ul>
    <il>bla</il>
    <il>blörtz</il>
</ul>

Monday, 23 April 2018

[DBeaver 5.0.x] Application "org.jkiss.dbeaver.core.application.standalone" could not be found in the registry.


From time to time DBeaver CE refuses to start with mentioned exception. Apparently it is able to write bork in its own configuration such that it cannot process it properly itself. To fix this, remove config directory:
${HOME}/.dbeaver4/configuration
Earlier versions (3.x at least) have been affected too.

Saturday, 7 April 2018

[CUPS] Samsung ML-2525W

  • I was not able to make WLAN work
  • URL: ipp://192.168.178.26/ipp
  • Driver: Samsung ML-2525W, 2.0.0 ← probably a ppd I saveguard at my subversion repository Documents/software/ML-2525W.ppd
  • Resolution: 600 dpi ← does 1200 dpi work as well?
  • Media size: A4
  • Airpressure: High ← why that, it's a laser printer???

Thursday, 5 April 2018

[LibreOffice Calc] ERR:502 in vlookup (sverweis)

Make sure that the referenced column is not outside the defined area. hlookup/wverweis probably analogous.

[git] Create a local branch from another branch

From the active branch git checkout -b <LOCAL_BRANCH> From a donator branch git checkout -b <LOCAL_BRANCH> <DONATING_BRANCH...