Thursday, February 17, 2011

For God's sake people, keep your business logic in one place! - Part II

So what's the big deal about keeping your business logic in one place?

Well, for starters, you're going to save your company a lot of money down the road and save probably yourself or another programmer tons of headache every time a little thing goes wrong.

So what can go wrong? Well, if you've been in the reporting business, or written many programs that actually got used, or built out any infrastructures for businesses to hold and move and display their data (like I've been doing the last 15 years) then you know that there's plenty that can go wrong.

The simplest and possibly the most frustrating is simply the customer saying to himself,

"Hmmm... these numbers don't look right. I was expecting something a little different. I bet something's wrong with the data."
So they write up a trouble ticket or send you an email or IM you with this deep logical distrust of your data.

What do you do?

Well, you can do like most IT people do. Say,
"Nope, the data looks good here. Must be something on your end"
If that don't work, option #2 is,
"That would be something caused by so-and-so process at my source. Sorry I can't do anything. But here's the name of the guy that might be able to help you."
(Options #1 and #2 basically are just "he-did-its" pointing North and South, upstream or downstream, to somebody else in line... an ancient IT tactic going back to the pyramid-building Jewish slaves in Egypt.)

But ultimately, if the customer is hard-headed, and other distracting "emergencies" don't pop up instead, it'll come back around to you and you'll have to investigate whether or not the data is getting screwed up somewhere. And where do you go? Well, you have to go top to bottom, beginning to end or where the data starts to where the data ends. And why? Because business logic is everywhere.

Now, if you are just a reporting geek, then that's not so hard because IT hasn't given you any real access to see all the magic they do. (Remember how the Wizard of Oz preferred to hide behind the curtain?) In that case you use option #2 and give them the company salute--that's where you shrug your shoulders and mumble "mmi-donno."

If you're IT, or a reporting geek with privileges, then you have to chase down the problem. And since you or someone else was stupid or lazy enough to toss the business logic all over like an angry baboon slinging feces on the walls, then you get to hunt and dig and use your genius analytical skills and your vast amount of extra hours to try and figure this thing out.

And if there is no problem, THEN, you get to try and hold the hand of the customer and explain over and over again all the different places the data changes at and prove to him that 2 + 2 is supposed to equal  5 and if you're lucky another crisis will crop up and this customer will go away.

NOW.....

If you had obeyed my simple rule of For God's sake people, keep your business logic in one place! you could pleasantly schedule a half hour meeting with the customer, share your desktop, and go,
"Well let's look and see if we can find your data problem Mr. CussToMe",

pull up the whole data flow and go,
“Well, here 2+2=4, ... and next right here 2+2=4, and downstream further yes, 2 plus 2 still equals 4... now we get to the BUSINESS LOGIC layer... hmmmmm ... ah yes... well what's this? Ole' Bobby here must have changed my code! Because it says here that 2+2-5. Heck, I’m pretty sure that’s not right. I'll fix it right away Mr. CussToMe. Thank you for bringing this to our attention. Wow, if only we had someone with your brains working for our team!"

And your job would be done.

Now isn't that a lot nicer?

Labels: , , , , , ,

For God's sake people, keep your business logic in one place!


For God's sake people, keep your business logic in one place. Don't be spreading it all over the board. Some in stored procedures, some in the views, some in the extraction-transformation-load layers (ETL), and some in the presentation layer, yet again some in an Excel by end consumers.


You guys understand fully what "Business Logic" is right? Are you sure? Well, think about it.


Anytime data itself is CHANGED (added, subtracted, recalculated, interpreted, ignored, or even RENAMED--yes, even renamed--because when you 'alias' a data field you've just given it YOUR understanding of what that field means in your mind--giving it 'business logic.')


Here’s an easy example of the last one. Certain data has three fields: Svc_BUID, Cust_BUID, and Order_BUID. You (the data-mover/code-writer middle man) figure, "Hey, this is all Services data, so obviously these people want to see the service business unit ID, so I'll alias that field--",SVC_BUID as 'BUID'." You just added Business Logic. Bam!


The exception (or better understanding) of that rule that:

Business Logic = anytime data itself is CHANGED,


is when you are dealing with the META-data. THAT is ok to mess with and you can spread that all over the board without scattering the golden rule of integrity in good data design ( keep your business logic in one place, in case you forgot already).


You do fully understand what "Meta Data" is right? Are you sure? Well, think about it.


"Meta" is ancient Greek for "above" or "over." Meta data is that abstracted concept of any information that isn't the information itself, but is ABOUT the information. (You have to squint one eye and tilt your head a bit to fully get this.) Meta-data is all that wonderful stuff that a database surrounds the actual data with. So yes, meta-data is the data type itself (int? varchar? nvarchar?), whether it's in XML, or a RDBMS, or on-the-fly bits, all the history of when, who, and where data came from, and again it is also the field name itself--which is the border of the data itself-- and actually belongs in BOTH categories--"data" AND "meta-data."


So, all meta-data CAN be altered, changed, adjusted, transformed, and slung about however you want.


That, in fact, IS the job of the pure IT person. To make one storage point of data properly talk to another storage point of data without actually changing the data itself. These "storage points" of data are things like the Oracle, the SQL Server, the Informatica process, the DTS package, the spreadsheet, even the PowerPoint or the ".txt", ".doc", ".xml", ".html", or ".dat" file type. (Even whether it's Unicode, ASCII, ANSI, UTF-16 etc. character type.) That is all meta-data.


So, let’s recap.


The main lecture point here was going to be:  For God's sake people, keep your business logic in one place.


But, we really had to back up and clearly define what business logic is. And to do that we had to clearly understand the difference between data and meta-data.


So if you’ve changed the data, you’ve added Business Logic. If you’ve changed the meta-data, good for you, hopefully it works, do it anywhere and everywhere you feel like. It doesn’t matter. For God's sake people, keep your business logic in one place!


Business logic: Anytime data itself is changed.

Labels: , , , , , , ,

Friday, February 11, 2011

Teradata Express Tools and Connection Drivers

VS C++ Express - compiler by Microsoft for compiling Stored procedures and UDTs in
Teradata
http://www.microsoft.com/express/Downloads/
Teradata Express download tools including Ole data providers
http://www.teradata.com/downloadcenter/
Build Your Own Enterprise Data Warehouse

Ingredients:
  • 1 Teradata 
  • 1 Oracle
  • 1 Informatica

Teradata Express 13 for Windows:
Teradata Support Links and User Forums:
Teradata Support Links
Teradata User forms
 
Oracle 10g for Windows (or Linux):
Obtain and install from you company or get an easy Express edition: http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
 
 
 
Informatica:
 
Hard Part--Configuring the connection string to Oracle for the repository and editing the tnsnames.ora. You won't know you have problems with this untill you are installing the Informatica and it is trying to connect to your existing Oracle.
 
Tips:
  1. Alias HAS to be FULL domain name (i.e. ms.aus.amer.dell.com)
  2. Service name HAS to be FULL domain.  (i.e. ms.aus.amer.dell.com)
  3. Instance = name only (i.e. ms)
  4. All this can be changed in text only in the tnsnames.ora file
  5. Configing the install though requires ONLY the full name.  (i.e. ms.aus.amer.dell.com) since SERVICE_NAME and ALIAS are now the same.
  6. DO NOT use the help in Informatica on this suggesting "World", etc. It only confuses the issue.
  7. A good resource on this is http://www.databasejournal.com/features/oracle/article.php/3092461/Connecting-with-Oracle.htm
  8. Many many googled people have this problem and I found no real solid answers. (lots of different answers)
  9. Example  tnsnames.ora file:
# tnsnames.ora Network Configuration File: D:\oracle\product\10.2.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA.amer.microsoft.com=
  (DESCRIPTION=
    (ADDRESS=
      (PROTOCOL=IPC)
      (KEY=EXTPROC0)
    )
    (CONNECT_DATA=
      (PRESENTATION=RO)
      (SID=PLSExtProc)
    )
  )
ms.amer.microsoft.com=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = mycomputer.amer.microsoft.com)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = ms.amer.microsoft.com)
      (INSTANCE_NAME = ms)
    )
  )

Useful tools:
CMD LINE:
Install tips:
  • Uninstall any previous Oracles and delete all registry keys, reboot then delete all folder structures and temp files.
  • During install uncheck the "Create Starter Database".
  • Take in all defaults except switch to character sets to UTF-8 under tab option.
  • When completed, run the Database Configuration Assistant in program files from Windows Start.
  • Next run the Net Config Assistant. Walk through defaults and Finish!
  • Check services.msc and see if Oracle products are running.
  • If included in license, log on to your admin through browser with http://machine_name.domain_if_included:1158/em
Running:
  • First thing I do is log in through browser and copy the SYSMAN user and give my self a new login. Simple name with same password. Add rights if wanted.
  • Then I fire up TOAD (software frontend for Oracle) and configure it to my new database.
  • Schema = Login name; Instance
  • This is where you get to config your tnsname.ora file. This guides your TOAD to services. Examples are in sample folder.
  • Port = 1521; Server = <full name from set up>; Config for the Listener can be found in web front-end on front page link. It gives the network data needed for tnsnames.ora file.
  • Example: (ADDRESS=(PROTOCOL=TCP)(HOST= mycomputer.amer.microsoft.com)(PORT=1521))
Help:
Some help and guidance available here but I don't recommend going the Windows Server 2003 and VMWARE route as described.