Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 20th, 2007, 7:10 AM   #1
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
c# datatable vs MySql table...

which one of these would be more efficient in terms of speed etc for storing temporary data? (mysql table would be accessed from C#)

the temporary data may or may not be "small"....
programmingnoob is offline   Reply With Quote
Old Aug 20th, 2007, 7:49 AM   #2
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 383
Rep Power: 4 xavier is on a distinguished road
Send a message via Yahoo to xavier
Temporary ... from day to day ? or minute to minute ?

What exactly are you trying to do ?
__________________
Don't take life too seriously, it's not permanent !
xavier is offline   Reply With Quote
Old Aug 20th, 2007, 9:41 AM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
There is really a lack of information to give you any beneficial advice.

Normally, MySQL database content is used to populate DataTables in C#.
The concept of "small" is relative, what you consider small may not be what we consider small. If the transactions on the data are fairly frequent and/or you need to use that data elsewhere in the program, then use a MySql table.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 20th, 2007, 5:34 PM   #4
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by xavier View Post
Temporary ... from day to day ? or minute to minute ?

What exactly are you trying to do ?

for example, a table containing information of all the users online...

so its temporary in that sense...
programmingnoob is offline   Reply With Quote
Old Aug 20th, 2007, 5:58 PM   #5
programmingnoob
Hobbyist Programmer
 
Join Date: Feb 2006
Posts: 154
Rep Power: 3 programmingnoob is on a distinguished road
Quote:
Originally Posted by Infinite Recursion View Post
There is really a lack of information to give you any beneficial advice.

Normally, MySQL database content is used to populate DataTables in C#.
The concept of "small" is relative, what you consider small may not be what we consider small. If the transactions on the data are fairly frequent and/or you need to use that data elsewhere in the program, then use a MySql table.
wow I was expecting exact opposite reply...
I was expecting you to say "if the data are fairly frequent and/or you need to use that data elsewhere in the program , then use a C# table"!!
I mean wouldnt accessing data from MySql table take longer than C# datatable? ... or maybe I am missing something very fundamental
programmingnoob is offline   Reply With Quote
Old Aug 20th, 2007, 6:59 PM   #6
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Bad choice of words on my part....

Of course accessing the data from a C# datatable would be faster than accessing from MySQL tables.

If its speed you want then anything close to the source would be the best. If its maintenance or reuse outside of that program, then MySql would be best. If the C# datatable grows too large, it has a potential to become more difficult to manage and perhaps even slower to access than if it were stored in MySQL.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 20th, 2007, 7:56 PM   #7
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Quote:
Originally Posted by programmingnoob View Post
for example, a table containing information of all the users online...
So you want a table that has a single column for user id? That gets a row added to it when someone logs in? And a row removed from it when they log out? In a typical website, one does not log out as much as quit clicking links. I never pressed log out 2 hours ago, but I'm just now shown as online. You could remove old entries every minute but that would be kind of silly. And what if you need to determine if 'Bob' is online? You mean you have to use two tables just for that?

Tables are usually used for distinct entities that are related to entities in other tables (relational databases) after all. A post has one user id. With one query you can find all of the posts made by 'Bob', even though he used to be name 'xxBobSlaY3rxx', because the id didn't change. Just his username in the user table did.

What I'm getting at is that being online is a property of a user. Users do not have multiple 'onlines', and 'onlines' certainly don't have multiple users. What you would want to do is add a column for 'last page visit', and SELECT for users which have a last page visit withing 10 minutes of the current time, for example. Or if it's a more stateful meaning of 'online', like being connected to a game server, make it a bool instead.


Databases are for storing data such that:
1. You can store a lot of it, available when needed

World of Warcraft has millions of accounts, and multiple characters per account. If you cancel an account, you stop getting bills, but all of the data stays there indefinitely to make it easier to come back. The forums might have years of searchable content, but most of the posts will not be viewed today, tomorrow, or ever again.

2. You can get to it

The data is in one place and accesible from any language or system that can communicate with it. You can pick about any language and there will be a libraries for the major databases. The World of Warcraft auth server has to check your password. The realm servers have to load your character data. The billing software has to get your acct. status, type, cc#, etc. The account management pages have to show account history, handle password changes, character transfers, and so on. The forums have to access the posts, but have to join with other tables to allow login, display of in-game rank/status, character names and pictures. Just in that example, a database allows Java servlets, in-house servers, and some random billing system to work together, with the ability to add in more tables and data as time goes on and features have to get added and others get replaced.

3. Fast

Databases are very good at what they are intended to do. You can query to find or modify exactly the data you want, even if pulling in multiple tables with a large number of rows and various constraints. Thinking ahead as far as structure certainly helps, but as time goes on different queries will be needed, so people need databases to guarantee that they can get the tiny fraction of the data that they need to their app for processing within a reasonable amount of time. It is the job of the database to find everything that you need to know about user X among the 10,000,000 others, but it is the job of the programmer to use it afterwards. Don't keep asking the database for stuff that you should just hold on to instead. In WoW, the realm servers will get all of the info about your character when you log in and is from then on responsible for it. A character can only be in one place at a time -- it is only when you log out that the server has reason to forget about it, and tell the database about that shiny new sword you found in the meantime. Yes, databases are fast, but ram is a hell of a lot faster. It will, however, immediately update your login state immediately, as this is important to other systems. But login state for a given user doesn't change every fraction of a second either. Don't store purely temporary stuff that has no meaning outside of your single app. You probably can't optimize your code better than the code in the database, but it is dealing with much more data and takes longer to access due to little things like the speed of light. It's slower.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mysql get last 10 records in a table kruptof Other Web Development Languages 3 Jun 29th, 2007 9:23 AM
MySql Error paulchwd Other Web Development Languages 8 Feb 27th, 2007 1:37 PM
mysql table view require()or suggestions. piercy PHP 15 Apr 28th, 2006 6:29 AM
Tutorial - Using MySQL in C# Darkhack C# 12 Jan 17th, 2006 9:28 AM
Simple Perl / MySQL Problem.. pls help! domquemo Perl 0 Jan 11th, 2006 4:08 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:47 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC