Red Gate forums :: View topic - Multi-Property Uniqueness
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Data Generator 2
SQL Data Generator 2 forum

Multi-Property Uniqueness

Search in SQL Data Generator 2 forum
Post new topic   Reply to topic
Jump to:  
Author Message
MartinH



Joined: 15 Apr 2005
Posts: 64

PostPosted: Wed Jan 11, 2012 1:51 pm    Post subject: Multi-Property Uniqueness Reply with quote

Is it possible to generate unique values for a field where the uniqueness is determined by more than one field?

For instance, I am generating sales receipts and the ticket number (integer) can't repeat when two fields coincide. The fields are ShopNumber (integer) and TillNumber (integer), so there should be no repeats for the combination ShopNumber+TillNumber+TicketNumber.

Is this possible?

Thanks,
Martin.
Back to top
View user's profile Send private message
peter.peart
Site Admin


Joined: 02 Sep 2008
Posts: 362
Location: Top floor, RG towers with the cool kids

PostPosted: Thu Jan 12, 2012 2:37 pm    Post subject: Reply with quote

Thanks for your post. Unfortunately, It's not possible to have data generated based on relationships between columns (unless it's PK > FK).

I suppose in this instance, if the value of the integer isn't important, you could use a RegEx for each column that specified a value between certain values that was different for all columns, i.e:

ShopNumber = 1 - 2000
TillNumber = 2001 - 4000
TicketNumber = 4001 - 6000

Or something along those lines.

HTH!

Pete
_________________
Peter Peart
Red Gate Software Ltd
+44 (0)870 160 0037 ext. 8569
1 866 RED GATE ext. 8569
Back to top
View user's profile Send private message Send e-mail
MartinH



Joined: 15 Apr 2005
Posts: 64

PostPosted: Thu Jan 12, 2012 3:54 pm    Post subject: Reply with quote

Peter:

If this is not available off-the-shelf, could I do it with a custom generator?

If this is (in theory) possible, I will look into writing one.

Thanks,
Martin.
Back to top
View user's profile Send private message
peter.peart
Site Admin


Joined: 02 Sep 2008
Posts: 362
Location: Top floor, RG towers with the cool kids

PostPosted: Thu Jan 12, 2012 4:10 pm    Post subject: Reply with quote

Hi Martin,

It should be possible. There's an article on our Simple Talk website which explains how to do this in more detail:

http://www.simple-talk.com/dotnet/.net-framework/embedding-ironruby-and-the-dlr-into-sql-data-generator/

HTH!

Pete
_________________
Peter Peart
Red Gate Software Ltd
+44 (0)870 160 0037 ext. 8569
1 866 RED GATE ext. 8569
Back to top
View user's profile Send private message Send e-mail
MartinH



Joined: 15 Apr 2005
Posts: 64

PostPosted: Thu Jan 19, 2012 7:26 pm    Post subject: Reply with quote

Peter:

Yes, that will work fine. I'll write my own generator to support this scenario,

Thanks for the help.

Regards,
Martin.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group