Click here to Skip to main content
15,886,873 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: a generic question about database table Pin
Eddy Vluggen25-Jan-23 4:54
professionalEddy Vluggen25-Jan-23 4:54 
GeneralRe: a generic question about database table Pin
jschell25-Jan-23 5:38
jschell25-Jan-23 5:38 
GeneralRe: a generic question about database table Pin
Eddy Vluggen25-Jan-23 5:48
professionalEddy Vluggen25-Jan-23 5:48 
GeneralRe: a generic question about database table Pin
Al_Brown25-Jan-23 22:07
Al_Brown25-Jan-23 22:07 
GeneralRe: a generic question about database table Pin
trønderen25-Jan-23 7:59
trønderen25-Jan-23 7:59 
GeneralRe: a generic question about database table Pin
Eddy Vluggen25-Jan-23 8:59
professionalEddy Vluggen25-Jan-23 8:59 
GeneralRe: a generic question about database table Pin
Jeremy Falcon25-Jan-23 11:14
professionalJeremy Falcon25-Jan-23 11:14 
GeneralRe: a generic question about database table Pin
Mike Winiberg25-Jan-23 20:30
professionalMike Winiberg25-Jan-23 20:30 
Although it used SQL as the backend, I remember a Customer Relationship Management system called Maximiser that took a similar approach. There were, ISTR just two tables, one to hold all the relatively constant client data itself and one to hold the collection of notes linked to that.

In the Maximiser app there were complex joins on one table producing 'subtables' that held various views on the data. Some columns contained numbers that indicated what other columns actually held! I was given the job of moving all the data held in this system to another SQL based program.

It took ages (in the absence of any database schema documentation) to unravel the various actual combinations of joins required to get what we wanted. Here's just one query to extract a little of the info: All the tables named as a, b, c, d etc duplicate joins used in 'built-in' queries on the maximiser database.

I thought you might find an example of the stuff I had to build mildly amusing 8)

-- Build the View of the Maximiser data that shows what we want and store it

SELECT     
CASE 
	WHEN c.Record_Type = 1 THEN c.Name
	WHEN c.Record_Type = 31 THEN d.Name + ' - ' + c.First_Name + ' ' + c.Name
	WHEN c.Record_Type = 2 AND len(c.Firm) > 0 THEN c.Firm
	WHEN c.Record_Type = 2 AND len(c.Firm) < 1 THEN c.First_Name + ' ' + c.Name
	WHEN c.Record_Type = 32 THEN 
	(
		CASE 
			WHEN len(d.Firm) > 0 THEN d.Firm + ' - ' + c.First_Name + ' ' + c.Name
			WHEN len(d.Firm) < 1 THEN d.First_Name + ' ' + d.Name + ' - ' + c.First_Name + ' ' + c.Name 
		END
	)
	ELSE c.Name
END AS Company,
CASE
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN e.Address_Line_1 
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.Address_Line_1
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN f.Address_Line_1
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN  g.Address_Line_1
	ELSE c.Address_Line_1
END AS Address_1,
CASE 
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN e.Address_Line_2 
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.Address_Line_2
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN f.Address_Line_2
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN  g.Address_Line_2
	ELSE  c.Address_Line_2
END AS Address_2,
CASE 
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN e.City
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.City
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN f.City
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN  g.City
	ELSE  c.City
END AS City,
CASE 
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN e.State_Province
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.State_Province
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN  f.State_Province
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN  g.State_Province
	ELSE  c.State_Province
END AS State,
CASE 
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN  e.Zip_Code
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.Zip_Code
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN  f.Zip_Code
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN  g.Zip_Code
	ELSE  c.Zip_Code
END AS Zip,
CASE 
	WHEN c.Address_Id > 0 AND c.Record_Type IN (1, 31) THEN  e.Country
	WHEN c.Address_Id < 1 AND c.Record_Type = 31 THEN  g.Country
	WHEN c.Address_Id > 0 AND c.Record_Type IN (2, 32) THEN  f.Country
	WHEN c.Address_Id < 1 AND c.Record_Type = 32 THEN      g.Country
	ELSE c.Country
END AS Country,
CASE 
	WHEN n.Type = 0 THEN  'Manual Note'
	WHEN n.Type = 1 THEN  'Mail - Out' 
	WHEN n.Type = 2 THEN  'Phone Call'
	WHEN n.Type = 3 THEN  'Timed Note'
	WHEN n.Type = 4 THEN  'Transfer'
	WHEN n.Type = 5 THEN  'Task'
	WHEN n.Type = 6 THEN  'Reserved' 
	WHEN n.Type = 7 THEN  'Reserved'
	WHEN n.Type = 8 THEN  'Opportunity'
	WHEN n.Type = 12 THEN 'Customer Service'
	ELSE  'Unknown'
END AS Activity_Type,
n.DateCol, n.TextCol, n.Owner_Id, n.Client_Id, n.Contact_Number, n.Note_Type,
'    ' AS sndex 
INTO BookerNotes
FROM
	dbo.AMGR_Client_Tbl AS c 
	LEFT OUTER JOIN dbo.AMGR_Client_Tbl AS d ON c.Client_Id = d.Client_Id AND d.Contact_Number = 0 
	LEFT OUTER JOIN dbo.AMGR_Client_Tbl AS e ON c.Client_Id = e.Client_Id AND c.Address_Id = e.Contact_Number 
	LEFT OUTER JOIN dbo.AMGR_Client_Tbl AS f ON c.Client_Id = f.Client_Id AND c.Address_Id = f.Contact_Number 
	LEFT OUTER JOIN dbo.AMGR_Client_Tbl AS g ON c.Client_Id = g.Client_Id AND g.Contact_Number = 0 
	RIGHT OUTER JOIN dbo.AMGR_Notes_Tbl AS n ON c.Client_Id = n.Client_Id AND c.Contact_Number = n.Contact_Number
WHERE c.Record_Type IN (1, 2, 31, 32)
GO

GeneralRe: a generic question about database table Pin
craig white 202126-Jan-23 4:43
craig white 202126-Jan-23 4:43 
GeneralRe: a generic question about database table Pin
englebart28-Jan-23 3:47
professionalenglebart28-Jan-23 3:47 
GeneralRe: a generic question about database table Pin
maze326-Jan-23 1:09
professionalmaze326-Jan-23 1:09 
GeneralRe: a generic question about database table Pin
Southmountain25-Jan-23 18:20
Southmountain25-Jan-23 18:20 
GeneralRe: a generic question about database table Pin
Southmountain25-Jan-23 18:24
Southmountain25-Jan-23 18:24 
GeneralRe: a generic question about database table Pin
jschell25-Jan-23 5:32
jschell25-Jan-23 5:32 
GeneralRe: a generic question about database table Pin
Gerry Schmitz25-Jan-23 6:19
mveGerry Schmitz25-Jan-23 6:19 
GeneralRe: a generic question about database table Pin
Southmountain25-Jan-23 18:21
Southmountain25-Jan-23 18:21 
GeneralRe: a generic question about database table Pin
Mycroft Holmes25-Jan-23 11:18
professionalMycroft Holmes25-Jan-23 11:18 
GeneralRe: a generic question about database table Pin
yacCarsten25-Jan-23 18:00
yacCarsten25-Jan-23 18:00 
GeneralRe: a generic question about database table Pin
lowracer25-Jan-23 20:50
professionallowracer25-Jan-23 20:50 
GeneralRe: a generic question about database table Pin
MikeCO1026-Jan-23 2:17
MikeCO1026-Jan-23 2:17 
GeneralRe: a generic question about database table Pin
Mark Starr26-Jan-23 4:11
professionalMark Starr26-Jan-23 4:11 
GeneralRe: a generic question about database table Pin
Peter Kelley 202126-Jan-23 4:53
Peter Kelley 202126-Jan-23 4:53 
GeneralRe: a generic question about database table Pin
englebart28-Jan-23 3:53
professionalenglebart28-Jan-23 3:53 
GeneralRe: a generic question about database table Pin
Daniel Anderson 20213-Feb-23 5:20
Daniel Anderson 20213-Feb-23 5:20 
Generalbased upon Engineer Pin
rnbergren25-Jan-23 2:43
rnbergren25-Jan-23 2:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.