Forum Moderators: coopster

Message Too Old, No Replies

Different or Same database?

which is preferable?

         

kkonline

5:14 am on Aug 16, 2007 (gmt 0)

10+ Year Member



I am posting this in this forum as i am concerned with the searchh part which has php in it.

I have a site on which i am using two tables> one for say articles and another for stories. There is no link between the two tables AT ALL and they are independent of each other. Also the tuples (rows) in both story and articles table varies.

Now my question is should i keep both stories and articles in the same database or should i make separate db for each of them. eg db_stories and db_articles having stories and articles respectively?

Does it make any difference if i use different db for each?

Also once the above thing is finalized I would like to have a common search; which will extract data from the articles and stories both stored in the db for a input by user.

Is it possible? If yes please explain/elaborate and give some examples to how to implement a common search?

Please give your comments/suggestions keeping the site security, easiness to work in mind andn any other parameter which is important?

Habtom

5:27 am on Aug 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



should i keep both stories and articles in the same database or should i make separate db for each of them

Unless you have a good reason, storing them in different db is one step to making the system more complicated.

If the two tables have similar fields, I would even recommend you in merging them and mark each row as an article or news.

Also once the above thing is finalized I would like to have a common search

Assuming the two tables has similar fields, based on your existing structure, you could create a temporary table (you don't have to do it for every search, may be stored procedure, or anything which can make it available when the search is needed). Putting them into one temporary table could make it easier for you displaying according relevancy, date, or any other factor which goes into the saerching.

Habtom

kkonline

5:39 am on Aug 16, 2007 (gmt 0)

10+ Year Member



I cannot merge the two tables as both of them are completely different in the structure.

However as insisted by you if i do merge them and make one table then i will have many values as NULL in the db. And secondly i can have another field whose having 1/0 implies it being an article or story.

For example a field has default value 0 in article then i will have to put a default value (wen posted from form) to be NULL as that field will not be applicable to story

Is this type of discrimination and having a lot of db values as null fine?

If i can merge then the search will be easy... I can have a tags field for both articles and stories which will be something like keyword similar to that in FLICKR!

So pls explain should i merge?... Now that i will have only one db...

what abt the site security if i have 2 db or 1 db... i feel having one form sql injected will only affect that db [though the structure is complicated to work with] but other one would be safe is that the case?

Habtom

6:20 am on Aug 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this type of discrimination and having a lot of db values as null fine?

I would have thought articles and news won't have much of a different DB structure, unless they are very much different from one another (even this for the sake of good Database desiging practices), having null values in DB won't harm you in anyway.

If merging doesn't sound good to you, try the temporary tables which by the way also can be created on the fly.

Habtom

kkonline

6:43 am on Aug 16, 2007 (gmt 0)

10+ Year Member



Firstly, the few tables are stories, article and quotes... so i wanted the thing for stories and quote table.

Where can i find an example of creating temperory table that to on the fly. Please throw a little light on this kind of technique and how to implement it.

Habtom

6:58 am on Aug 16, 2007 (gmt 0)