문제

I'm making a webapp for fun. There are 'user's, and each user has disjoint data.

Each user has a number of 'routines'. (again these are COMPLETELY unique to each user).

Each 'routine' has a number of 'step's (COMPLETELY unique to the routine), and each 'step' has a number of 'substep's (again, completely unique to the step).

I am currently storing this information in straight-up SQL tables. So there is a Users table, a Routines table, a Steps table, and a Substeps table. It's nice because when I click on a step, only substeps pertaining to that step are loaded (and the cached).

But, there are beginning to be an overwhelming number of different php files, as each table has attributes unique to it. Should I be storing this in XML on the SQL table? What would you do?

도움이 되었습니까?

해결책

In an object-oriented approach it makes sense to me that you might have a PHP file representing each class in your object model - User.php, Routine.php, Step.php, Substep.php - and import those into the PHP class which represents your main web app controller. You might also break out persistence of these object to and from the database into one additional file, or one file per object type - this isn't an overwhelming # of files in an object-oriented program, and it's far preferable to putting everyhing into one big file.

다른 팁

Consider using a self-referencing table -- single table that holds the parent step ('routine'), and then each child-step. For example:

tbl_routine
ID | ParentID | Title
1  | <null>   | Wash the Car
2  | 1        | ..Fill the bucket
3  | 2        | ....Add 1oz Soap
4  | 2        | ....Add 4ltr Water
5  | 1        | ..Put the nozzel on the hose
...

And then use a CTE / recursive query to pull the routine and all of it's steps & sub-steps out.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top