Welcome Guest, Not a member yet? Register   Sign In
Node type database structure.
#1

[eluser]CoolGoose[/eluser]
Hi all.
I want to do a very basic cms for personal use but i can't seem to get the database structure right (my database relationship skills are low).
The "problem" is that i want every item in the database to be like a node. So posts/categories/users/topics whatever should be node items with corresponding options to each.
Something like
Code:
nodes (id, type_id)
types (id, node_id, option_id)
And the option_id could be separate tables with different names.

Does anyone have another idea ?

Thanks a lot for your time.
#2

[eluser]Sam Dark[/eluser]
Are you trying to reinvent Drupal? Read something about is's structure and ideas. It's built by pretty smart people.
#3

[eluser]m4rw3r[/eluser]
You could have a Page_base class which all the other "special" pages extend.
Then in your database, have a column where you store the 'name','id' or 'path to file with class'.
Ex.
Code:
Table for storing pages:
ID    TITLE       TYPE    DATA
2     index       NULL    'whatever data the page can use, serialized by the page class'
3     specialpage 2       'A serialized string from the class Blog_Index_page.'

Table for types:
ID    CLASSNAME       FILE
2     Blog_Index_page 'The path to the file with Blog_Index_page'

Then the class which represents a page have a method called load(), which takes the serialized string and unserializes it and inits all internal data with that data.
The class also have a method called something like render(), which returns the page or something you can use in your templates.
The Blog_Index_page can then override those methods to make it behave in a special way.

This is only a simple example on how it can be done, there are many more ways you can implement different page types.
#4

[eluser]CoolGoose[/eluser]
@Sam Dark:
I'm fully aware about Drupal and no i don't intend to make a Drupal clone. Thanks for the heads up though.
The problem with Drupal is that it's not a MVC like CMF and i don't really like it. It's great for a CMS and making some sites fast with views / cck & co.

@m4rw3r
That's a bit too db intensive and it's not just about page types. Sam got it pretty well with the Drupal example.

Maybe i should look over the drupal db structure more (Drupal future 7 preferably because it will try to treat all the elements as nodes even comments / signatures).

I'm open to more suggestions.
Thanks again for your help.
#5

[eluser]Sam Dark[/eluser]
@CoolGoose: MVC is not always good. For example there are some topics here at CI forum (one is mine Wink) where people are asking how to call Controllers from Views. It's not strict MVC but it's really flexible.
#6

[eluser]CoolGoose[/eluser]
I understand your point of view but let's not turn this into a MVC vs something else debate.
After all it's a matter of taste Wink.
#7

[eluser]Sam Dark[/eluser]
OK.

My DB variant:

Code:
//common for all nodes
nodes
---
id
parent_id - parent node id
type_id - ref. to node_types
name
created_on
modified_on

node_types
---
id
classname

Plus there'll be some node-specific tables.
#8

[eluser]CoolGoose[/eluser]
Thanks for your help. I'll keep you updated about the progress.




Theme © iAndrew 2016 - Forum software by © MyBB