Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

question for better understanding


Reply


3 Posts   261 Views

Avatar
timo

Community Member, 5 Posts

23 July 2014 at 8:12pm

New to this forum and hope I'm in the relevant section.
I am thinking about building a vocabulary trainer for different languages.
Until now i've been working on small sites with more or less uncomplicated data objects (dataobjectmanager).
It should be something like:

Language -> Page (i.e. English)
|
has_many Books
|
has_many Grades
|
has_many Lessons
|
has_many Words

Whats the best way to set up the site-structur (nested data objects ? ) in the CMS to comfortable feed this structure with data?
Or only one dataobjectmanager (Words) with fields (Language, Books, Grades, ...) and
different select-menues (Language .. Books .. etc.) to filter the needs?

What do you think?
All suggestions are welcome.

Thanks.
timo

Avatar
Willr

Forum Moderator, 5513 Posts

26 July 2014 at 11:18pm

Have a read of the 5th tutorial. This will introduce you to dataobject relationships and various approaches to follow http://doc.silverstripe.org/framework/en/tutorials/5-dataobject-relationship-management.

Avatar
Mia

Community Member, 8 Posts

12 August 2014 at 9:29am

When it gets down to object orientation and design, it's much more than just related to SilverStripe.

Using your example to give you an idea of how you could go about it:

//these will control all the different languages and handle the displaying and usage of them
class PageLanguage extends Page{

}

class PageLanguage_Controller extends Page_Controller{
//simple example methods you might want to use in such a page

function listLanguages(){
}

function viewLanguage(){
}

function addLanguage(){
}
}

Then for the rest of your objects, they should each be independent:

class Language extends DataObject{
language type
description
etc.

has many books
has many grades
has many words
has many lessons
}

class Book extends DataObject{
author
date
description summary
etc.

belongs many languages
}

class Grade extends DataObject{
belongs many languages
}

class Lesson extends DataObject{
type
dates
description
lecturer
etc.

belongs many languages
}

//and the only reason I would make word a object is so that you can easily search and filter on them
class Word extends DataObject{
origin
usage
etc.

belongs many languages
}

This way, just by having a language object, you can control and change all its related objects. And all of that can be done is the language page, which should only be responsible for handling, alteration and displaying of all the other objects.