Firouziam
Firouziam

Reputation: 805

hierarchical information in doctrine and symfony 1.4

i have an entity with a lot of fields(like facebook user Information with multiple levels like Basic Information, Contact Information, and...). and i want to use it exactly like facebook . i mean i want several tabs to put related fields in there. the easiest way is to store all of them in a table but it's too nasty . is there any way to do this better? i know something about database hierarchical design, but is there a way to do this in symfony 1.4 and use it's form creator either?

thanks.

Upvotes: 1

Views: 651

Answers (2)

Grad van Horck
Grad van Horck

Reputation: 4506

First of all: where do you need help? In the view or in the model?

If you want it too look like Facebook, we're talking View. This has nothing to do with Symfony, but just HTML (with some CSS/JS probably).

If you're talking about how to store this information: the information your describing isn't "hierarchical". Hierarchical is about trees and things like that, most of the time with an almost infinite depth. Here you're talking about a strict structure (you, as developer, know exactly which fields you want to render, and define these yourself). You could look into Entity-Attribute-Value stores. But beware: when implementing some like this in mySQL, it won't be easy to do 'complex' queries. (Even a query like: "List all people in New York, older than 30 years old", is not rendered easy).

So why won't you go with a table with a lot of columns? There's nothing nasty about that! That you, as a human being, may have troubles viewing these data in phpMyAdmin, has nothing to do with how a computer manages this information ;-). You could split up the 'User' model in a seperate 'UserProfile' model (with a one-on-one relation), so you can easily refer to users on other pages (where you don't need all profile data).

Upvotes: 1

jgallant
jgallant

Reputation: 11273

You can use Doctrine Nested sets. It is basically a tree structure contained in your database. I have a demo of how this can be used, but the source code might scare you.

Take a look at the demo to give you an idea of what you can do. If you are leaning towards this option, then you should definitely check out the tutorial link I posted below to get started.

Demo

Source Code

Doctrine Nested Sets Documentation

Tutorial on Nested Sets

Upvotes: 0

Related Questions