Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Do I or don't I

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-12-01 : 18:03:54
I have a design issue - the first issue being that I can't decide if a database is the best way to do what I want (I suspect it is).

The problem I have is this.

We are trying to check that two computer programs (call them ST and MS) produce the same output. We have two sets of files that combine to provide the input to each program. (The files as a pairing probably form a natural key). They are a sample file and a reference file. There are two different reference files (F and R) and a whole load of sample files, for example:

No Sample File Reference File
1 1_1203_1F.ab1 1_1203_3F.ab1
2 1_1203_1R.ab1 1_1203_3R.ab1
3 1_1203_2F.ab1 1_1203_3F.ab1
4 1_1203_2R.ab1 1_1203_3R.ab1
5 1_1203_3F.ab1 1_1203_3F.ab1
6 1_1203_3R.ab1 1_1203_3R.ab1
7 U14680_MS__F_Synthesis_7335.scf 1_1203_3F.ab1
8 U14680_MS__R_Synthesis_7281.scf 1_1203_3R.ab1

etc...

When these pairs of files are input into Program ST they produce up to 14 output items (ST1,ST2,...ST14). When the same pair are put into program MS they will produce up to 3 output items (MS1, MS2, MS3).

At the moment they are performing a manual comparison of the outputs to see if they are the same - it seems to me that this is what computers (and particularly databases) are best at.

In addition to this there will only be a small amount of data input - essentially it will only be done a few times and I may even be able to BCP it in. There will be very few changes to the data ever and there will only be a handful of users ever - so the design can be optimised for querying.

Having said all this I've got my self confused about how to design it (it's been a long time since I designed a database), I'm almost thinking flat file would be best but wouldn't that be harder to query? Would this perhaps be a situation where I could use a cross join maybe?

To put it briefly - where do I start?

Many thanks

steve

To alcohol ! The cause of - and solution to - all of life's problems

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-12-01 : 20:32:27
Are you just trying to check that two files are the exact same?
Isn't there a dos command that compares files?

Other than that... what would some example of the output look like?

Corey
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-12-01 : 22:32:25
You can fc. It's a DOS command.


CREATE PROCEDURE sp_filecompare

--DECLARE @result INT EXEC @result = sp_filecompare 'c:\test.txt','c:\test1.txt',0,1,0,1,0,0 SELECT @result
--DECLARE @result INT EXEC @result = sp_filecompare 'c:\test.txt','c:\test1.txt',0,0,0,0,0,0 SELECT @result

@file1 VARCHAR(256),
@file2 VARCHAR(256),
@verbose BIT = 0,
@binary_only BIT = 0,
@case_insensitive BIT = 0,
@ascii_compare BIT = 0,
@unicode_compare BIT = 0,
@no_whitespace BIT = 0

AS

DECLARE @error VARCHAR(256)

--Make sure there are no incompatible switches.
IF (@binary_only = 1 AND @ascii_compare = 1)
BEGIN
SELECT @error = '@binary_only and @ascii_compare are incompatible switches.'
GOTO ERROR_HANDLE
END

--Declare objects.
DECLARE @cmd VARCHAR(4000)

CREATE TABLE #results(
ident INT IDENTITY(1,1) PRIMARY KEY,
result VARCHAR(4000))

--Create compare command.
SELECT @cmd = 'FC '
SELECT @cmd = CASE WHEN @binary_only = 0 THEN @cmd ELSE @cmd + ' /B ' END
SELECT @cmd = CASE WHEN @case_insensitive = 0 THEN @cmd ELSE @cmd + ' /C ' END
SELECT @cmd = CASE WHEN @ascii_compare = 0 THEN @cmd ELSE @cmd + ' /L ' END
SELECT @cmd = CASE WHEN @unicode_compare = 0 THEN @cmd ELSE @cmd + ' /U ' END
SELECT @cmd = CASE WHEN @no_whitespace = 0 THEN @cmd ELSE @cmd + ' /W ' END
SELECT @cmd = @cmd + @file1 + ' ' + @file2

INSERT #results(result)
EXEC master..xp_cmdshell @cmd

IF @@ERROR <> 0
BEGIN
SELECT @error = 'Error inserting into #results.'
GOTO ERROR_HANDLE
END

--Test results. If not verbose, return 0 for success or 1 for failure. Otherwise, return complete result.
IF @verbose = 0
BEGIN
IF (SELECT result FROM #results WHERE ident = 2) = 'FC: no differences encountered'
BEGIN
RETURN 0
END
ELSE
BEGIN
RETURN 1
END
END
ELSE
BEGIN
SELECT result FROM #results
END

IF @@ERROR <> 0
BEGIN
SELECT @error = 'Error returning results.'
GOTO ERROR_HANDLE
END

DROP TABLE #results

RETURN 0

ERROR_HANDLE:

RAISERROR(@error,16,1)
RETURN 1

GO


MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-12-02 : 04:35:42
The input files will be the same ones.

What I am interested in is comparing the outputs of the two programs.

So for example

When I look at the row I've numbered 1 above I might get the outputs
ST1 = 1342AC>A,372N/H>N$15
ST5 = 1422-1432insA
MS1 = 1342AC>A
(and NULL for all the others i.e. ST2, ST3, ST4, ST6,...ST14 and MS2 and MS3)

So with the file inputs 1_1203_1F.ab1 1_1203_3F.ab1 then program ST will produce
ST1 = 1342AC>A,372N/H>N$15
ST5 = 1422-1432insA
and program MS will produce
MS1 = 1342AC>A

In this particular case MS1 is the same as ST1 (as in the ST output we can ignore anything after a first comma) however there is no match for ST5 in the MS output so overall these don't match

I hope this clarifies a little, if not I will have another go at explaining

steve


To alcohol ! The cause of - and solution to - all of life's problems
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-02 : 05:23:54
so basically you have 2 programs for which you just want to test output and nothing else?
have you thought about Unit Testing. we use sourceforge's Nunit tests for stuff like that....

Go with the flow & have fun! Else fight the flow
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2004-12-02 : 05:27:32
Thanks Spirit

I haven't thought about unit testing. Mostly because I don't know what it is. I presume there are other programs that do the same thing (cost may be a factor here)

steve

To alcohol ! The cause of - and solution to - all of life's problems
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-12-02 : 07:15:22
nunit is free. we use Nunit.asp for asp UI testing and NUnit for testing data and stuff like that.
there is also T-sql testing unit TUnit which is still version 1.
http://nunitasp.sourceforge.net/
http://sourceforge.net/projects/nunit

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -