2

I am working on a site which provides coupons for online shopping sites. It provides discount coupons for shopping sites in India. But now the client wants to provide coupons for USA stores also. But offers available for Indian users are not useful for the USA users and vice versa.

Therefore there will be two versions of the site. One is for the Indian users and other is for the USA users.

But if a user from India searches for an offer which is not available in India but is available in the USA. Then it should appear in search results.

Now I am thinking of creating a new database for the USA users with exact same schema as that of the database for current users(Indian users).

But I would like to get advice from an expert.

4
  • Yes, this is a perfectly acceptable approach. You could also just replicate the tables you already have and add _usa to the name or something like that. The only thing that gets me is that offers should show to Indian users if there is one in the USA, which might help you to just replicate the tables inside the same database, so you can do joins, etc. Commented Dec 4, 2017 at 15:30
  • 1
    Your question is primarily opinion-based.. Commented Dec 4, 2017 at 15:30
  • FWIW, I wouldn't do this. Just have one database; it doesn't matter that Indian users and US users generally see different things. Commented Dec 4, 2017 at 15:37
  • Perhaps this answers the question for some Working with Databases in Multi module app Commented Dec 8, 2021 at 6:19

2 Answers 2

5

In the long run you might want to add more countries so I would do it by adding a country table kind of thing and something like offer_valid for offerid country id which would make a single offer valid for one country or more. Creating multiple databases would make the maintenance hectic.

Sign up to request clarification or add additional context in comments.

Comments

1

Creating a separate database or a separate table (by adding _usa to table name) for that matter does not make sense.. because the same can be achieved by creating a mapping table which maps offers/coupons to the country/countries for which it is valid and is more scalable as well.

Here is what I suggest:

countries: id, name

coupons: id, name, discount

coupon_country_mapping: id, country_id, coupon_id, is_active

6 Comments

I can do this for a single table but there are total 54 tables like brands, stores, ad_banners, etc. All these tables store data that will be exclusive to different countries.Eg: Some brands available in India will not be available in USA and vice-versa. Similarly, there will be some shopping stores that are available in India (like Flipkart) but not in USA. Therefore creating a mapping table for each table will not be an easy task.
you don't need to create a mapping table until there is a many-to-many relationship between entities like between Coupon and Country. In other cases, you can just add an attribute country_id in the tables to assign the country for which that entry is valid.
I thought of adding country_id for each table. But then I have to change many lines of code to accommodate country_id column.
it's a one time effort but will be very much scalable.. tomorrow if you need to add a new country, it will be a simpler task then again creating a new database
1. Code duplication 2. Maintenance overhead: say you want to add a new table or a new field in a table, you will have to do it in both the databases. Any piece of code change(query etc) has to be replicated
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.