Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old August 27th, 2003, 07:51 PM
devious_05 devious_05 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Victoria Australia
Posts: 26 devious_05 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Database design

I cant get my head around the way my superiors want my database to work...

Here is an example they want to work
Type in animal as a search and
Animal comes up - click on that and it branches
out to Dog, Cat, Duck etc then click on one of those
and it branches out to Wandering, missing, Feeding.

My initial idea was to have a main table with top headings such as Animal, Accounts, IT (areas of council)
then tables for each of the branches such as Dog,Cat,Duck
then tables for each of their branches such as wandering, missing.

However this could end up in thousands of tables and I think it would be a hell of a search because I dont know how to search all the tables.

Anyone got any ideas how this should work?
It confuses me!

Reply With Quote
  #2  
Old August 27th, 2003, 08:08 PM
christo's Avatar
christo christo is offline
Introspective
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Nov 2001
Location: London, UK
Posts: 3,296 christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level)christo User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Days 1 h 5 m 42 sec
Reputation Power: 101
Send a message via ICQ to christo Send a message via Yahoo to christo
that'll only be 3 tables - is that too much?

christo

Reply With Quote
  #3  
Old August 27th, 2003, 11:28 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,344 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 26 m 4 sec
Reputation Power: 891
actually just one table, with a recursive hierarchy, like the good old who-reports-to-whom employee table, or the category-subcategory-subsubcategory table, or...

the problem with three tables is that if you want to "promote" duck to the top level, you have to move it from one table to the other, but even worse, you have to move all its subcategories from the 3rd table up into the 2nd, and there goes all your pointers/links...


rudy

Reply With Quote
  #4  
Old August 28th, 2003, 06:16 AM
mitakeet's Avatar
mitakeet mitakeet is offline
Last Day: May 28, 2005
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2003
Location: Maryland
Posts: 4,575 mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level)mitakeet User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 8 h 5 m 34 sec
Reputation Power: 20
Presuming your db supports temp tables, access the data through a stored procedure, read the minimum amount of data into a temp table (it will likely have much more than what you are looking for, but ideally much less than the entire table(s)), index the temp table and run another query on it. Presuming you have adequate indexes on your master table(s), this should run quite quickly. I have done the same sort of thing where I do my own joins because the query optimizer (in Sybase, in this case, though the same thing does happen in MS SQLServer) is too brain dead to figure out the most efficient method.

You can use the exact same stored procedure, it just performs differently each time based on the input.
__________________

Left DevShed May 28, 2005. Reason: Unresponsive administrators.
Free code: http://sol-biotech.com/code/.
Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.

It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
--Me, I just made it up

The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
--George Bernard Shaw

Reply With Quote
  #5  
Old August 29th, 2003, 01:03 AM
devious_05 devious_05 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Victoria Australia
Posts: 26 devious_05 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
please note Im a beginner database builder(ie this is the first database i've ever built)

so to be honest I dont really understand what you are talking about mitakeet.

The recursive hierarchy table sounds like the best way to achieve what I need.
Can anyone point to me some resources for implementing something like this?

Thanks for all your responses anyway

Reply With Quote
  #6  
Old August 29th, 2003, 01:29 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,344 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 8 h 26 m 4 sec
Reputation Power: 891
The recursive relationship
http://searchdatabase.techtarget.co...x285649,00.html
free registration may be required

rudy

Reply With Quote
  #7  
Old August 29th, 2003, 07:28 AM
Silian's Avatar
Silian Silian is offline
Gogga
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Posts: 198 Silian User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
You r going 2 have 1 table looking something like this:

intID vcDescription intParent

1 Animals 0
2 Dog 1
3 Cat 1
4 Duck 1
5 German Shephard 2
6 Cross Breed 2

etc.

That way when someone clicks on animals, you get the id (which will be 1), and the just get everything whose Parent is the same as the ID.

Reply With Quote
  #8  
Old September 1st, 2003, 11:45 PM
devious_05 devious_05 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Victoria Australia
Posts: 26 devious_05 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Can this be done using an Access database?

Its going to be used through the company Intranet so what sort of interface would be best for coding?

I was hoping to use PHP.

How would I work it so that if someone clicks on animals it displays all the children and so oN?

I've been trying to look for tutorials on this and they mostly just explain what a recursive hierarchy table is not how to implement it

The search terms dont seem to return much relevant information.

Thanks again

Reply With Quote
  #9  
Old September 2nd, 2003, 10:27 AM
crimson117 crimson117 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: New York
Posts: 19 crimson117 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to crimson117 Send a message via AIM to crimson117 Send a message via Yahoo to crimson117
You're asking a few questions in one. I think the isues here are:

1. How to design the database
2. How to actually set up the database in mysql or access or whatever
3. How to get a web page to be an interface to the database


If this is really your first time doing a web/database project, start with a simple example like silian said; here's one of a management/reporting structure:

&nbsp;id - name - boss
101 - carl - 101
102 - josh - 101
103 - bets - 104
104 - luke - 102


In this case Carl is his own boss (he's the top boss).
Josh reports to Carl
Luke reports to Josh
Bets reports to Luke

1. make a table called HR
2. add those columns and records as I described above
3. write up some sql select statements for things you might want to do, such as:

find all 2nd tier people: select id, name from HR where boss=101
find all people who have a manager: select id, name from HR where boss != 101
find all people who are the boss of someone else: select id, name from HR hr1 where id IN (select distinct boss from HR hr2)

Now comes the hard part: read up in http://www.php.net to learn basic PHP and then http://us2.php.net/manual/en/ref.mysql.php to learn how to use PHP to talk to MySQL. I'm not sure whether PHP can talk to MS Access. Make some pages with links that call your queries. Try some different application designs; perhaps you'll have a different page for each task, or perhaps you'll have one page which dynamically includes whatever functions it needs.


Once you've done this practice exercise, you'll be ready to start working on the real project.

Good luck!


PS your database description was kind of vague. There are different things I'd recommend, based on how often the categories and data will change, and how important speed is to your database. If you let us know more, we may have more relevant help available to you.

Reply With Quote
  #10  
Old September 2nd, 2003, 10:31 AM
crimson117 crimson117 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: New York
Posts: 19 crimson117 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to crimson117 Send a message via AIM to crimson117 Send a message via Yahoo to crimson117
another thing to consider is not to store data by using descriptive table names. If you're storing 3 kinds of people, lets say Doctors, Teachers, and Workers; don't make 3 tables. Make one table called Person, and have one column be called "personType", and it can have a value of doctor, teacher, or worker.

If you're into object oriented database design, try to think of your database-world as objects with attributes. A doctor is a person with a persontype of doctor. A teacher is a person with a persontype of teacher, but otherwise, they're the same as a doctor; in that you need to know their name, address, phone, etc.

Reply With Quote
  #11  
Old September 3rd, 2003, 09:42 PM
devious_05 devious_05 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Victoria Australia
Posts: 26 devious_05 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cool

The reason my database description is vague is because thats the only description I've been given and I have to work out what to do based on that. to be honest I wish i had more information on what Im supposed to make but my boss seems to expect me to know. I believe the data will be changing frequently btw.

I have basic PHP skills and yes Access can interact with PHP because I have already achieved that.

Im just unsure how to search the KeyTerms field and then return the record/s with a link for each so that I can click on that link and then return all those further down in the hierarchy. so basically how can I call a query by clicking on a link?

another question.

With the recursive hierarchy database if I have say 10000 records in the one table am I going to get sufficient speed when querying??

Thanks in advance

dont mean to sound sucky but people are willing to offer so much of their knowledge here! its great

Reply With Quote
  #12  
Old September 3rd, 2003, 10:55 PM
crimson117 crimson117 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: New York
Posts: 19 crimson117 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to crimson117 Send a message via AIM to crimson117 Send a message via Yahoo to crimson117
Do you know how to pass parameters into a PHP document by putting them at the end of the url?

You can send in one param to tell it to do a certain pre-written query, and a second param to tell it to filter that query by the type the user clicked.

So your url might be:

http://www.myplace.com/app.php?acti...a&filter=Canine


A php function at the beginning of your page would read these url params and act accordingly; executing the QueryBeta query with "and type='canine'" appended to the end of it. Then you'd use the result set to create the records listed on the page.

See http://us3.php.net/variables.external for how to read parameters from the url using $HTTP_GET_VARS

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Database design


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump