Database programming question.

Status
You're currently viewing only klinzhai's posts. Click here to go back to viewing the entire thread.
Not open for further replies.

klinzhai

Ars Tribunus Militum
1,889
I've been shanghaid by the company I work for to write a database for a client. I basically thought it would be little problem, but then a kicker came in that I'm not sure how to deal with.

I'll try to explain it as simply as possible.

Each user has a unique ID, I was using this ID to simply keep track of their data within the various databases and tables, but I'm starting to get a little worried that the data will actually start to get excessively large. I'm wondering how I should deal with this. Each user could potentially have data in over 500 non duplicating fields. Several fields will be related and I was simply trying to keep the user data separate by the user ID and have several tables for related data, ending with between a dozen fields per table or so up to closer to about 50 fields. I'm worried that this will actually slow down the access for the database. Is there a problem with making tables with upwards of 50 to potentially 80 fields if the data is commonly related (and thus usually accessed at the same time) or should I try to keep it down below 30?

Everything I've been doing with databases up until now hasn't needed more than 25 fields for the mostpart, so it hasn't been an issue. This needs to be a very fast db, so does anybody have a good idea on how I should deal with this?
 

klinzhai

Ars Tribunus Militum
1,889
Let's see if I can help this out a little...

Let's say I have a table with 100 fields (not really out of the question), field b will be related to all other fields, field c will be related to b and maybe 12 others.

It's basically a tiered system where there will be several fields that may rarely be accessed, but when they are, they are accessed in relation to 1-5 others that would also be in the table. I was considering breaking it into groupings of data that would guaranteed go together, but if it's not really a performance issue of putting upwards of 250-300 fields in the same table, then I'll go ahead and do that, it would make more sense for the actual database.

There should only be one table that will require more than 75 fields organizing the data the way I'm thinking. I guess I'm just used to trying to keep the tables smaller for easy management and tracking. There is one small problem though that reboot stated and that's the number of records. I'm expecting it to be upwards of potentially 10-15 thousand records. I'm starting to think of ways to speed it up, but will it really be an issue where the users would see a pause of more than a second or two while data is being searched for, particularly if I have good key usage?

I'm using FreeBSD and MySQL right now for the initial development, but plan on going to full BSD and converting the db from MySQL over to Oracle when I get close to done with the database.

We might create a master db server that is centrally located and then use site servers to hold local data when a user logs in at a location to keep their info and occasionally updates the master server maybe every 3-10 minutes or so and when the user logs off.

I have a feeling that we're going to end up getting at least one DBA to handle this project in the end, but would prefer to avoid hearing him say "what moron designed this piece of crap?" when he sees the db structure that I built.

Any more suggestions? Thanks for those you've already given also, they've helped a lot.
 

klinzhai

Ars Tribunus Militum
1,889
You'll only need to start worrying about this when your tables get into the 100K-500K range.

Great... now I know that it won't be a problem I can relax about that for now.

those 12 fields should go in a different table, not in the same one.

OK, if I'm understanding you correctly then I'm going to end up with a very large number of tables.

Example:

Field A is related to fields A1-A12, field A1 is related to A1a-A1h, field A1a is related to fields A1a_1-A1a_15. It's not quite that bad, but it can be in some situations. Are you saying that A-M should be in one table, A1-A12 in another, A1a-A1h in another and A1a_1-A1a_15 in yet another? Would this potentially cause performance issues when I'm looking at say, 3000 records in table A-M, 1200 in table A1-A12, another 350 in table A1a-A1h and around 60 in table A1a_1-A1a_15? If it would actually increase performance in the long run then I'd be more than happy to stick with that format, as it was kind of what I was looking at already, I think that I'd potentially end up with a lot of redundant data fields though. Then again, keeping the actual data size down isn't all that important, keeping it fast is.

Why develop on MySQL if you plan to go to Oracle?

I haven't worked with Oracle before yet and have most of my experience on MySQL. I figured that I'd design it on MySQL, where I know it better and then go to Oracle when the basic design is solid, so if I screw up something in Oracle I still have something to fall back on. Maybe I should just run out and get Oracle, but I'm not really sure if my boss will pony up the cash for it. I'll look around and see if I can find some good pricing for it. Maybe I can talk him into picking up a copy for dev purposes.
 

klinzhai

Ars Tribunus Militum
1,889
If A1 has a value of "1" for user X and user Y, then will all the subsequent values of A1a-A1h be the same for users X and Y? If this isn't true, then splitting the tables like that won't be terribly useful (and may hurt you in the long run), except to minimize the amount of extra (empty) fields you're storing.

All of the entries that I'm talking about are going to be numerical and an example would be as follows:

User X:
A = 950
A1 = 439
A2 = 148
A1a = 210
A1b = 135
A1c = [empty]
A1d = 42

There will be several tables that users won't even have entries in and if they do, sometimes the user data will be minimal in that particular table. The data won't be consistent from user to user and no two users should end up with the same data except by fluke.

It would vastly save space on storing empty data to split the fields but I'm more concerned about speed in the long run. The mandate that came down was "It can never be slow".


Oh yeah, got on Oracle's site and it would appear that they have copies for download but I'm wondering if these are timebombed versions or just a bit hamstrung. If it's just hamstrung to perform like crap, I can live with that if it means that I can do the actual development on Oracle instead of trying to import it later. I do have some time on this project so I can learn about Oracle as I do it without too much in the way of time constraints to hinder me.

Has anyone worked with the Oracle free download version?
 

klinzhai

Ars Tribunus Militum
1,889
The more I think about it the more tiering the db makes sense. Even though it will mean a lot more tables, it will mean less data per table, right?

The 'main' tables (I think that there will be 3 or 4 of them) will have data for every user... things like fname, lname, location, etc... while the other tables will be more specialized, specific data that not all users will use. Most users won't use the majority of the tables, so those tables will be smaller, maybe 300 rows of data.

Sorry for all the noob questions, but I haven't gotten into large dbs before and speed due to size was never a real issue for them.
 

klinzhai

Ars Tribunus Militum
1,889
without insulting you intelligence, what is your experience / formation with design / modeling?

Don't worry, I wouldn't consider it an insult and to be honest, my experience is minimal. I'm well organized and from what I know that's easily half the battle. I think that I've decided to go after the several tables model instead of one rediculously large table. I thought that it would be a mess that would be at best difficult to track, at worst a nightmare that is nearly impossible to get out of without several weeks preparation.

I would suggest reading a book on D/B design and/or data modeling first.

I've got a couple that I use for reference. I probably need to start getting deeper into the innards of the books though.

In particular, there's only so much I can think of for user related data, it should really be narrow.
(name, adress, department_no, salary, etc...)

Can you give examples of what you're considering putting into a user table ?

It's going to be a custom invoicing/mailing list/purchase tracking, etc... program. I guess they tried to get it on the market but they couldn't find anything that did everything that they wanted it to do and getting something modified so that it would do all they wanted would have cost as much, if not more than what we're supposed to be charging them. I think it's overkill, but at this stage of their planning they're not really open to input, so I'm more than happy to burn their money while learning as much as possible and trying to get the job done right (or near close as possible) the first time.
 
Status
You're currently viewing only klinzhai's posts. Click here to go back to viewing the entire thread.
Not open for further replies.