Re: Accessing Multiple database

2008-10-02 Thread GrandiJoos

Hi,

As stated by Anja Liebermann, your solution for having city1_xxx
tables is as bad as having 4 different databases.

The best solution would be

 your thought
I want to make different database for every city and one common
database. suppose this website have city1, city2, city3 then there
will be 4 different database.
common-database
city1-database (with tables 1 to 10)
city2-database (with tables 1 to 10)
city3-database (with tables 1 to 10)


 Ideal solution
1) 1 database (the 'common' one...)
2) Add the 10 tables from each of the city databases, which have the
same structure, to the common database
3) Add 1 field, the cityId for instance, to determine what city the
information is about.
4) Make sure you create foreign keys to 'really' reference cities!!!

Example:
city_infos: (cityid, cityname, inhabitants, ...) {from the common
'database', information per city} cityid is primary key
shops (cityid, shopname, size, location, ...) {the 'shops' table from
each of the cities databases} cityid is foreign key to
city_infos.cityid
--

NOTE: You might want to perform step 3 first to each table in each
database and then export the contents of each table (and the structure
once) and then import them into the common database.

In some cases a single field does not suffice but a HABTM [1]
relationship is necessary.
Furthermore, I would suggest you look into data modelling in general.
I suppose [2] and [3] are a good start but any book about database
design would suffice.

Hope this helps (and if not, let me (/us) know ;) )

GrandiJoos

[1] http://book.cakephp.org/view/312/Models
[2] http://en.wikipedia.org/wiki/Data_modeling
[3] http://en.wikipedia.org/wiki/Relational_model


On 2 okt, 14:00, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Well I wouldn't make different Database's unless you really really
> must!
> Instead stick with 1 DB, but more tables in the DB!
>
>  your thought
> I want to make different database for every city and one common
> database. suppose this website have city1, city2, city3 then there
> will be 4 different database.
> common-database
> city1-database
> city2-database
> city3-database
> 
> Well from what I see it is almost finished  just miss writen
>
> so how about just calling all those tables (which would be in a
> different DB by you)
> city1_xxx
> city2_xxx
> city3_xxx
>
> And change the Prefix (implimented in CAKE) in your code to what you
> need ;-) Finished
> Querying between them is then a piece of Cake since normal Join's can
> be used between the Tables
> This also saves a LOT of Queries which you be needed to get
> information out of every single DB one by one ...
>
> Greetings Oliver
>
> On Oct 1, 5:56 pm, "Liebermann, Anja Carolin"
>
> <[EMAIL PROTECTED]> wrote:
> > I guess different tables is as bad a different databases. Why don't you 
> > have your 10 tables and have the city correlation via an city_id field? 
> > That is what I would do.
>
> > Greetings Anja
>
> > -Ursprüngliche Nachricht-
> > Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von 
> > bookme
> > Gesendet: Mittwoch, 1. Oktober 2008 13:25
> > An: CakePHP
> > Betreff: Re: Accessing Multiple database
>
> > Thanks your reply!
>
> > Each city specific datbase have 10 tables..how can i make them?
> > suppose common database has brands table and city1 database has stores 
> > table, becuase every city has different stores and no realtion to other 
> > city. so making diffrent database for different city is good I think.
>
> > Can any one help me?
>
> > On Oct 1, 3:13 pm, techiguy <[EMAIL PROTECTED]> wrote:
>
> > > sorry i mean to say one common database and have tables
> > > city1,city2,city3 instead of separate databases??
>
> > > On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I am working on a highly dynamic web content site.
> > > > This website have two types of data one is common data and second is
> > > > city specific. The homepage has listing of all the available cities
> > > > which then takes you to that specific cities page.  All the code for
> > > > a specific city is the same as any other city, the only difference
> > > > is the data being pulled from the database only relates to that
> > > > specific cities.
>
> > > > I want to make different database for every city and one common
> > > > database. suppose this website have city1, city2, city3 then there
> > > > will be 4 different dat

Re: Accessing Multiple database

2008-10-02 Thread [EMAIL PROTECTED]

Well I wouldn't make different Database's unless you really really
must!
Instead stick with 1 DB, but more tables in the DB!

 your thought
I want to make different database for every city and one common
database. suppose this website have city1, city2, city3 then there
will be 4 different database.
common-database
city1-database
city2-database
city3-database

Well from what I see it is almost finished  just miss writen

so how about just calling all those tables (which would be in a
different DB by you)
city1_xxx
city2_xxx
city3_xxx

And change the Prefix (implimented in CAKE) in your code to what you
need ;-) Finished
Querying between them is then a piece of Cake since normal Join's can
be used between the Tables
This also saves a LOT of Queries which you be needed to get
information out of every single DB one by one ...

Greetings Oliver

On Oct 1, 5:56 pm, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> I guess different tables is as bad a different databases. Why don't you have 
> your 10 tables and have the city correlation via an city_id field? That is 
> what I would do.
>
> Greetings Anja
>
> -Ursprüngliche Nachricht-
> Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von bookme
> Gesendet: Mittwoch, 1. Oktober 2008 13:25
> An: CakePHP
> Betreff: Re: Accessing Multiple database
>
> Thanks your reply!
>
> Each city specific datbase have 10 tables..how can i make them?
> suppose common database has brands table and city1 database has stores table, 
> becuase every city has different stores and no realtion to other city. so 
> making diffrent database for different city is good I think.
>
> Can any one help me?
>
> On Oct 1, 3:13 pm, techiguy <[EMAIL PROTECTED]> wrote:
>
> > sorry i mean to say one common database and have tables
> > city1,city2,city3 instead of separate databases??
>
> > On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I am working on a highly dynamic web content site.
> > > This website have two types of data one is common data and second is
> > > city specific. The homepage has listing of all the available cities
> > > which then takes you to that specific cities page.  All the code for
> > > a specific city is the same as any other city, the only difference
> > > is the data being pulled from the database only relates to that
> > > specific cities.
>
> > > I want to make different database for every city and one common
> > > database. suppose this website have city1, city2, city3 then there
> > > will be 4 different database.
> > > common-database
> > > city1-database
> > > city2-database
> > > city3-database
>
> > > Can I do my database design int this way in CakePHP? I tried for
> > > this but don't know how can I access multiple database with a single
> > > query in CakePHP?
> > > Please tell me what is better way making this city specific site?
>
> > > Thanks- Hide quoted text -
>
> > - Show quoted text -

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Accessing Multiple database

2008-10-01 Thread bookme

Thanks your reply!

Each city specific datbase have 10 tables..how can i make them?
suppose common database has brands table and city1 database has stores
table, becuase every city has different stores and no realtion to
other city. so making diffrent database for different city is good I
think.

Can any one help me?


On Oct 1, 3:13 pm, techiguy <[EMAIL PROTECTED]> wrote:
> sorry i mean to say one common database and have tables
> city1,city2,city3 instead of separate databases??
>
> On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I am working on a highly dynamic web content site.
> > This website have two types of data one is common data and second is
> > city specific. The homepage has listing of all the available cities
> > which then takes you to that specific cities page.  All the code for a
> > specific city is the same as any other city, the only difference is
> > the data being pulled from the database only relates to that specific
> > cities.
>
> > I want to make different database for every city and one common
> > database. suppose this website have city1, city2, city3 then there
> > will be 4 different database.
> > common-database
> > city1-database
> > city2-database
> > city3-database
>
> > Can I do my database design int this way in CakePHP? I tried for this
> > but don't know how can I access multiple database with a single query
> > in CakePHP?
> > Please tell me what is better way making this city specific site?
>
> > Thanks- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Accessing Multiple database

2008-10-01 Thread techiguy

sorry i mean to say one common database and have tables
city1,city2,city3 instead of separate databases??

On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am working on a highly dynamic web content site.
> This website have two types of data one is common data and second is
> city specific. The homepage has listing of all the available cities
> which then takes you to that specific cities page.  All the code for a
> specific city is the same as any other city, the only difference is
> the data being pulled from the database only relates to that specific
> cities.
>
> I want to make different database for every city and one common
> database. suppose this website have city1, city2, city3 then there
> will be 4 different database.
> common-database
> city1-database
> city2-database
> city3-database
>
> Can I do my database design int this way in CakePHP? I tried for this
> but don't know how can I access multiple database with a single query
> in CakePHP?
> Please tell me what is better way making this city specific site?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Accessing Multiple database

2008-10-01 Thread techiguy

y dont u make table in a common database instead of separate
databases?

like u have one common table and have city1,city2,city3 as its
tables.

On Oct 1, 12:31 pm, bookme <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am working on a highly dynamic web content site.
> This website have two types of data one is common data and second is
> city specific. The homepage has listing of all the available cities
> which then takes you to that specific cities page.  All the code for a
> specific city is the same as any other city, the only difference is
> the data being pulled from the database only relates to that specific
> cities.
>
> I want to make different database for every city and one common
> database. suppose this website have city1, city2, city3 then there
> will be 4 different database.
> common-database
> city1-database
> city2-database
> city3-database
>
> Can I do my database design int this way in CakePHP? I tried for this
> but don't know how can I access multiple database with a single query
> in CakePHP?
> Please tell me what is better way making this city specific site?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---