0

I would like to ask you guys if you could review my database design. I think it is quite self-explanatory, but to be absolutely clear:

My goal is to make an application which has a super flexible user management (which is why the groups are in tree-form and the groups and users have a habtm relationship) and a super modular way to build pages (which is why the pages consist of widget-blocks).

The reason I made users and profiles separate is because the users table will not change and is only needed for authentication and authorization. However, the profiles table will change according to the wishes of the client. So it might not have a signature, but an avatar field instead. Or maybe it will be completely empty / not exist at all.

A widget could be anything, it could be a poll, it could be a piece of content, it could be a navigation, it could be a collection of comments, whatever.

The reason I chose to make subdomains, locales and layouts separate tables instead of just putting the names into pages is because I want to limit the options that are available to the client. Just because I have a three-columns.ctp in my layouts folder doesn't necessarily mean I want the client to be able to choose it.

Same goes for the widgets. And besides limiting choice, not every plugin, controller and action in my plugins-folder is a widget, so I need a table to clarify which are.

A block is a widget on a page which sits in a container (e.g. the right column in a 3 column layout) at a particular position which is decided by the index (lower index means higher).

So that's my explanation, what do you guys think? Is this as good as it can be? Or do you have (a) suggestion(s) to make it even more flexible and modular.

[edit] Oh and to be clear, the widgets will of course have their own tables to store the information they need to store.

Evert
  • 2,022
  • 1
  • 20
  • 29

1 Answers1

0

Well, I think that everything is great except "profiles".

When you try to get data from a logged user:

$this->Auth->user();

I don't think that you will get data about "profiles" so you will have to find profile by $this->Auth->user('id') etc. I think that you should merge "profiles" and "users" tables into "users" table.

So when you want to save, let's say, "signature" you should just put it in $this->request->data; and call $this->User->save($this->request->data); and the signature will be updated.

EDIT:

You can leave it the way it is but, to get other data than user, you will have to put:

$id = $this->Auth->user('id');
$current_user = $this->User->findById($id);
  • Thank you. I think I will keep them separate, because of the fact that the profiles table will be more dynamic than the users table. I don't mind that it will cost me some more code. :-) Thanks for the input though! – Evert Aug 02 '12 at 10:15
  • No problem. If you find this answer helpful, you can mark this answer as "answer" or, at least, vote up. :) –  Aug 02 '12 at 11:23
  • I can't vote up because I don't have enough reputation yet. And I don't want to set this answer as THE answer, because there might still be someone who has a great tip for me. Sorry for that. – Evert Aug 02 '12 at 11:34
  • I understand. :) You've made a good question so here is a vote up for you. ^^ –  Aug 02 '12 at 11:47