473,322 Members | 1,538 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Data generator help!!

Hi everybody!!
I really need help for my assignment... I want to make an application
in c# to populate the database (sql server 2005), so that later on we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
but i dont know how to get the data types of the columns etc....
Please do reply with your valuable suggestions... and ideas.

Thanks

Mar 15 '07 #1
5 1786
Shum wrote:
Hi everybody!!
I really need help for my assignment... I want to make an application
in c# to populate the database (sql server 2005), so that later on we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
but i dont know how to get the data types of the columns etc....
Please do reply with your valuable suggestions... and ideas.

Thanks
For something like this you would need to use ado.net 2.0's metadata
functionality to examine the structure of the db and tables etc.

You can find out more about these features at:

http://msdn2.microsoft.com/en-us/lib...43(VS.80).aspx

Hope that helps

Kindest Regards

Simon
Mar 15 '07 #2
On Mar 15, 10:39 am, "Shum" <shumy...@gmail.comwrote:
I really need help for my assignment... I want to make an application
in c# to populate the database (sql server 2005), so that later on we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
That sounds like a bad way of getting even slightly realistic data.
You should make your generator understand what the database is
actually representing, and try to model it. For instance, I've written
code to model users browsing to web sites, taking into account how
long a user might stay within a website, how often they will be
fetching data, what kind of concurrency to expect at different times
of day etc.

Using straight random values will give a completely different data
distribution to reality, which could well affect performance tuning
etc. Also, for fields that are used as foreign keys, you can't just
give a random ID, as you're likely to violate constraints.

Jon

Mar 15 '07 #3
On 15 Mar, 11:15, Simon Harvey <notha...@hotmail.comwrote:
Shum wrote:
Hi everybody!!
I really need help for my assignment... I want to make an application
in c# to populate the database (sql server 2005), so that later on we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
but i dont know how to get the data types of the columns etc....
Please do reply with your valuable suggestions... and ideas.
Thanks

For something like this you would need to use ado.net 2.0's metadata
functionality to examine the structure of the db and tables etc.

You can find out more about these features at:

http://msdn2.microsoft.com/en-us/lib...43(VS.80).aspx

Hope that helps

Kindest Regards

Simon- Hide quoted text -

- Show quoted text -
Alternatively you can do it through SQL:
The following will retrieve table columns and datatypes. I left the
index stuff in at the end as I agree with what Jon says below. You
could use it to identify what fields are key fields and then do god
knows what with that :)
DECLARE @TableName AS varchar(50)
SELECT @TableName ='results' -- <--- change this to your table!

-- databases
SELECT name, dbid FROM master..sysdatabases

-- Table and columns
SELECT SO.Name as SO_Name, SO.ID as SO_ID, SC.name as SC_Name,
SC.colid AS SC_ColID, ST.name AS ST_Name
FROM sysobjects SO JOIN syscolumns SC ON SO.id = SC.id INNER JOIN
systypes ST ON SC.xtype = ST.xtype
WHERE SO.name LIKE @TableName AND SO.xtype = 'U'

-- Table indexes
SELECT @TableName AS SO_Name, SI.indid AS SI_IndID, SI.name AS
SI_Name
FROM sysindexes SI
WHERE SI.id IN (select id FROM sysobjects WHERE name LIKE @TableName
AND xtype = 'U')
AND SI.name NOT LIKE '_WA_Sys%'

-- Table indexes with index keys
SELECT SO.name AS SO_Name, SI.name as SI_Name, SC.name AS SC_Name
FROM sysobjects SO INNER JOIN syscolumns SC ON SO.id = SC.id
INNER JOIN sysindexkeys SIK ON SIK.id = SO.id AND SC.colid =
SIK.colid
INNER JOIN sysindexes SI ON SI.id = SO.id AND SIK.indid = SI.indid
WHERE SO.name LIKE @TableName AND
SI.name NOT LIKE '_WA_Sys%'
--ORDER BY SI_Name

Mar 15 '07 #4

Hmmm... yea im in great fix... someone told me to use data adapetr to
get the database information and datatypes... yea u r right i cant
just generate a random number for ID... dont know how to deal with
that...........



On Mar 15, 10:13 pm, "DeveloperX" <nntp...@operamail.comwrote:
On 15 Mar, 11:15, Simon Harvey <notha...@hotmail.comwrote:


Shum wrote:
Hi everybody!!
I really need help for my assignment... I want to make an application
in c# to populate the database (sql server 2005), so that later on we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
but i dont know how to get the data types of the columns etc....
Please do reply with your valuable suggestions... and ideas.
Thanks
For something like this you would need to use ado.net 2.0's metadata
functionality to examine the structure of the db and tables etc.
You can find out more about these features at:
http://msdn2.microsoft.com/en-us/lib...43(VS.80).aspx
Hope that helps
Kindest Regards
Simon- Hide quoted text -
- Show quoted text -

Alternatively you can do it through SQL:
The following will retrieve table columns and datatypes. I left the
index stuff in at the end as I agree with what Jon says below. You
could use it to identify what fields are key fields and then do god
knows what with that :)

DECLARE @TableName AS varchar(50)
SELECT @TableName ='results' -- <--- change this to your table!

-- databases
SELECT name, dbid FROM master..sysdatabases

-- Table and columns
SELECT SO.Name as SO_Name, SO.ID as SO_ID, SC.name as SC_Name,
SC.colid AS SC_ColID, ST.name AS ST_Name
FROM sysobjects SO JOIN syscolumns SC ON SO.id = SC.id INNER JOIN
systypes ST ON SC.xtype = ST.xtype
WHERE SO.name LIKE @TableName AND SO.xtype = 'U'

-- Table indexes
SELECT @TableName AS SO_Name, SI.indid AS SI_IndID, SI.name AS
SI_Name
FROM sysindexes SI
WHERE SI.id IN (select id FROM sysobjects WHERE name LIKE @TableName
AND xtype = 'U')
AND SI.name NOT LIKE '_WA_Sys%'

-- Table indexes with index keys
SELECT SO.name AS SO_Name, SI.name as SI_Name, SC.name AS SC_Name
FROM sysobjects SO INNER JOIN syscolumns SC ON SO.id = SC.id
INNER JOIN sysindexkeys SIK ON SIK.id = SO.id AND SC.colid =
SIK.colid
INNER JOIN sysindexes SI ON SI.id = SO.id AND SIK.indid = SI.indid
WHERE SO.name LIKE @TableName AND
SI.name NOT LIKE '_WA_Sys%'
--ORDER BY SI_Name- Hide quoted text -

- Show quoted text -

Mar 17 '07 #5
I guess the question is, do you actually have some data you want to store
in the database? Your description made it sound like you were just going to
create some columns and put some random data in there.

Robin S.
-------------------------------------
"Shum" <sh******@gmail.comwrote in message
news:11**********************@l77g2000hsb.googlegr oups.com...
>
Hmmm... yea im in great fix... someone told me to use data adapetr to
get the database information and datatypes... yea u r right i cant
just generate a random number for ID... dont know how to deal with
that...........



On Mar 15, 10:13 pm, "DeveloperX" <nntp...@operamail.comwrote:
>On 15 Mar, 11:15, Simon Harvey <notha...@hotmail.comwrote:


Shum wrote:
Hi everybody!!
I really need help for my assignment... I want to make an
application
in c# to populate the database (sql server 2005), so that later on
we
can use that large amount of data for mining etc.
So any of you who knows how to go about implementing this thing are
free to reply...
I was thinking of doing it this way: first get the list of tables in
the database, then get the data type of the coulumn, if the data
type
is int then generate a random number and insert that number into the
field.. move onto the next column.... and this is how all the tables
will be filled...
but i dont know how to get the data types of the columns etc....
Please do reply with your valuable suggestions... and ideas.
Thanks
For something like this you would need to use ado.net 2.0's metadata
functionality to examine the structure of the db and tables etc.
You can find out more about these features at:
>http://msdn2.microsoft.com/en-us/lib...43(VS.80).aspx
Hope that helps
Kindest Regards
Simon- Hide quoted text -
- Show quoted text -

Alternatively you can do it through SQL:
The following will retrieve table columns and datatypes. I left the
index stuff in at the end as I agree with what Jon says below. You
could use it to identify what fields are key fields and then do god
knows what with that :)

DECLARE @TableName AS varchar(50)
SELECT @TableName ='results' -- <--- change this to your table!

-- databases
SELECT name, dbid FROM master..sysdatabases

-- Table and columns
SELECT SO.Name as SO_Name, SO.ID as SO_ID, SC.name as SC_Name,
SC.colid AS SC_ColID, ST.name AS ST_Name
FROM sysobjects SO JOIN syscolumns SC ON SO.id = SC.id INNER JOIN
systypes ST ON SC.xtype = ST.xtype
WHERE SO.name LIKE @TableName AND SO.xtype = 'U'

-- Table indexes
SELECT @TableName AS SO_Name, SI.indid AS SI_IndID, SI.name AS
SI_Name
FROM sysindexes SI
WHERE SI.id IN (select id FROM sysobjects WHERE name LIKE @TableName
AND xtype = 'U')
AND SI.name NOT LIKE '_WA_Sys%'

-- Table indexes with index keys
SELECT SO.name AS SO_Name, SI.name as SI_Name, SC.name AS SC_Name
FROM sysobjects SO INNER JOIN syscolumns SC ON SO.id = SC.id
INNER JOIN sysindexkeys SIK ON SIK.id = SO.id AND SC.colid =
SIK.colid
INNER JOIN sysindexes SI ON SI.id = SO.id AND SIK.indid = SI.indid
WHERE SO.name LIKE @TableName AND
SI.name NOT LIKE '_WA_Sys%'
--ORDER BY SI_Name- Hide quoted text -

- Show quoted text -


Mar 17 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Rick | last post by:
Hello, I'm having trouble with submitting my form when checking to see if data is present in the user-inputted fields. What I want to happen is for the user to input various pieces of data,...
3
by: JC Mugs | last post by:
I need help with a project, that has two things driving me crazy. 1. I have number entries that wish to have the data enter from the right, so that when you type in 80, it is .80 or eighty...
14
by: Zeeshan7 | last post by:
=NZ(DMax("","Table1")+1,1) This can be added in a form field / properties / Data tab in Default Value to generate auto number. Please help to add the same in a table 'default value? Secondly,...
0
by: DhavalPatel1983 | last post by:
Hi All, I need ur help in Visual Baisc for Data Report. Description ========= I have one Project Which include One Data Envirnment,Data Report,Form Which contain Listview,Text box, and...
0
by: iHateProg | last post by:
I am looking for a day of birth generator that will use MONTH DATE AND YEAR born to generate the BIRTH DAY from 1900-2000. Ex:- If someone was born on April 10, 1990. what day of the week were they...
6
by: Mike Langworthy | last post by:
i can not seem to get this code to work. someone please help using System; using System.Collections.Generic; using System.Text; namespace ConsoleApplication1 { class Program {
1
by: helpfulmaid | last post by:
Hello, I want a function that when it detects the left mouse button is pressed down, will generate and cycle 5 random number/letter combinations as fast as it can in a printed space. If I let off...
5
by: kanley | last post by:
I have a main table with a text description field. In this field, its populated with a string of data. I need to identify from this string of data the name of the vendor using some keywords. I...
9
by: bhass | last post by:
I'm trying to make a basic RSS feed generator. I'm still a newb and I really need help. My aim is to have the user input all their desired settings then create an XML file in the same directory with...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.