FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


How would you represent a MySQL database visually





Possum
Hi

I have written a small database and have embedded the data for each of my web pages into a Tree component. Now I want to convert this data over to a MySQL database. How would I do this.



Also if you know of any instances of a MySQL database being represented in a treeview I would love to know about it.

Thank you..
jmraker
When I do it I have 1 or 2 fields for the tree.

1. A field for the parent_id. Where 0=root, or ""=root (Something to match the primary key)
2. The order field, (if thiere's already an order field, a 2nd one)

Without the order field you'd have to fetch the tree recusively
SELECT * FROM tree where parent_id=0 then a SELECT * FROM tree WHERE parent_id=? for every record found and again deeper if a record is found every time the tree is printed

With the order field you could fetch them in the correct order in one database query. Where your program that edits the table does the recursion to order the records based on the order they should appear on the page. Where the 1st item is 0 and the last item printed on the page would be the highest number
Fire Boar
jmraker has the right idea, though I'd suggest using null rather than 0 or "". Reason being, null is compatible with InnoDB, while 0 is not (assuming you're using constraints). It's always best to try and be compatible with InnoDB even if you don't plan to use it. It also makes sense intuitively: for the root of the tree, the parent is not 0; there is no parent.
Possum
I could write a program to convert the file over to MySQL.

I guess I need to learn all about MySQL..

So much to learn..And so little time Smile
Related topics
Cron Job to Backup MySQL Database
Mysql database problem
PHPBB MYSQL Database Question.
MySQL database for a forum
Mysql database size?
Connect to MySql database
[MySQL database] Password and username
insert data to mySQL database problem
MySQL Database!?
Delete data from MySQL database problem!!
MySQL database
Problem connecting to MySQL database with PHP [RESOLVED]
Need Help with mysql database of DragonflyCMS
Help importing CSV file into MySQL database
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.