Welcome, Guest
Username: Password: Remember me

TOPIC: [HOW TO] Split Projects - large project management

[HOW TO] Split Projects - large project management 21 Aug 2013 18:04 #10871

  • BTB300
  • BTB300's Avatar
  • Offline
  • Moderator
  • Posts: 415
  • Thank you received: 132
  • Karma: 47
Hi There
I have been "Cooking" for a while now and have many split projects and links to other components... just thought i would share an easy way to split projects and access data from tables belonging to your Cook Projects (can also be adapted for other components)

Firstly I must say that many of my larger projects will build without issues in Cook 2.5 - A major improvement over the early days Thanks admin ;) From the early days i soon found that splitting projects assists in "manageability" of large scale projects. (Yes there is overheads such as duplicated code...)

With a little careful planning splitting projects becomes easy but before we start we must take in depth look at how Cook tables are generated for each project.

Case Study: A Large Scale Retailer
This retailer has a head office, a warehouse, and serveral shop outlets
Their user interface has been build with Cook Self Service
Their data source and user interface is hosted on a single server somewhere in the big www cloud.

Along with this they plan to sell products on the internet at a later date
Data Lists and Tables
Warehouse: needs access to
suppliers list
warehouse inventory list
warehouse storage location list
employees list
shop list
.....
.....
Head office: needs access to
suppliers list
warehouse inventory list
accounts list
shop sales records
employees lists
shop list
item price lists
.....
.....
Shop outlets: needs access to
item price list
shop sales records
employees list
warehouse inventory list
.....
.....
For manageability four projects have been created using Cook Self Service
another project will soon be created for online sales

From the above we can see that a number of tables are common to some or all projects so lets start thinking about split projects

The project group has a common name - Retailer
The head office project name will be - Retailer HeadOffice
The warehouse project name will be - Retailer Warehouse
The shop outlet project will be called - Retailer Shopoutlet
The fourth project contains data tables "common" to all projects and will be called Retailer

Lets look at the project table names and how they are created by the Cook Builder in each project

Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets

Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_headofficeemployees
shop outlets - retailler_headofficeshopoutlets

Retailer Warehouse => table name
employees - retailer_warehouseemployees
shop outlets - retailer_warehouseshopoutlets
warehouse Inventory - retailer_warehousewarehouseinventory
shopoutlet Inventory - retailer_warehouseshopoutletinventory

So how do we link all these tables to read from the same data tables?
simple - add an extra "trim marker" to the table alias in the right "spot"
in this case the "trim marker" will be "exttbl"
the exttbl "trim marker" is added to all tables that are external to the project

Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets

Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_headofficeexttblemployees
shop outlets - retailler_headofficeexttblshopoutlets
warehouse inventory - retailer_headofficeexttblwarehouseinventory
shopoutlet inventory - retailer_headofficeexttblshopoutletinventory

Retailer Warehouse => table name
employees - retailer_warehouseexttblemployees
shop outlets - retailer_warehouseexttblshopoutlets
warehouse inventory - retailer_warehouseexttblwarehouseinventory
shopoutlet inventory - retailer_warehouseexttblshopoutletinventory

Note: The warehouse inventory example above shows is a special case where the warehouse inventory table will technically be an "internal" table of retailer warehouse
An Example -
want to add a separate table for warehouse employees to perhaps hold more data than the employees table? Simply create the table and put the "trim marker" here... warehouse employees - retailer_warehouseexttblwarehouseemployees

So now what do we need to do?
- download your project
- extract the project zip file
- Adjust your MySQL install and un-install files
- perform a simple search and replace on the whole project folder and sub folders - site, admin ...
- its just one string in the format #__projectgroup_projectnameexttbl replaced by #__projectgroup_
- Zip your project
- Upload and install

Heres How

Adjust your MySQL install and un-install files: admin\sql\install.mysql.utf8.sql and admin\sql\uninstall.mysql.utf8.sql
I usually do this first before any search and replace - makes it easier to make sure all external tables are not deleted by accident when un-installing a project that links to the main table of another project

in the MySQL install file
- delete or comment out the create table statement for all "external" tables that contain the trim marker "exttbl"
- remove the just the "extbl" trim maker from the create table statement for "internal" tables
- see note above in retail_warehouse to understand "internal" and "external" tables

in the MySQL uninstall file
- delete or comment out the drop table statement for all "external" tables that names contain the trim marker "exttbl"
- remove the "extbl" trim maker from the drop table statement for "internal" tables
- see note above in retail_warehouse to understand "internal" and "external" tables

Search and Replace
Retailer Project
Do nothing leave as is because these are the common tables

Retailer Head Office Project
Search: #__retailer_headofficeexttbl
Replace: #__retailer_

Retailer Warehouse Project
Search: #__retailer_warehouseexttbl
Replace: #__retailer_

AND FINALLY THE RESULTS!!! :blink:

Retailer => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets

Retailer Head Office => table name
accounts - retailer_headofficeaccounts
employees - retailer_employees
shop outlets - retailer_shopoutlets
warehouse inventory - retailer_warehouseinventory
shopoutlet inventory - retailer_shopoutletinventory

Retailer Warehouse => table name
employees - retailer_employees
shop outlets - retailer_shopoutlets
warehouse inventory - retailer_warehouseinventory
shopoutlet inventory - retailer_shopoutletinventory

Have you adjusted your MySQL install and uninstall files?
- Yes Great!
- No? Do it now!

Zip your project and upload

I must note that the above search and replace routine only allows you to connect to the same data table it will not load the view of the external component
additional search and replace routines (not covered here) must be done to load the view of another component

As you can see with some careful planning you can now start the retailer_online project and its easily link it to any data in all of the projects above

Happy Cooking!
Last Edit: 21 Aug 2013 20:22 by BTB300.
The administrator has disabled public write access.
The following user(s) said Thank You: admin, dyoungers

[HOW TO] Split Projects - large project management 22 Aug 2013 10:56 #10884

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Thank you for your precious help BTB300.

K++
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.071 seconds

Get Started