0

I am creating an application which requires the user to register. All data entered by user will be stored in this table called "customer". Now part of the information being collected is the address but I don't want to congest the table structure and would like to store address as an object (city, address, post code, etc).

What's the best practice: create an address table and refer the table through foreign key in the customer table or store the customer address as an object and store it in customer table?

I am not sure how parse fully functions so looking for your experience in the answer.

Thanks

2 Answers 2

1

I faced this exact problem a few months ago, and solved it by having a pointer in the customer object structure to the additional data. Note that if you do this, you'll need to make sure to include the pointed to field in future customer queries, or the data won't be fetched.

Retrospectively, I'm not sure I'd recommend splitting the objects up. It does create a more normalised data structure, but Parse fights against this in several ways:

  1. You have to remember to include the pointed to field in all future queries. This is a pain.
  2. You can only follow pointers up to a certain depth within a query (I think 3?)
  3. Parse charges you by the database access, so denormalised data can be an issue.
  4. Parse doesn't really support atomic operations or transactional queries, so it's easy to get your data into an inconsistent state if you're not careful about when you save. For example, you update your customer record, go to change the address record, and have the second query fail. Now you're in a "half updated state", and without transaction rollback, you'll have to fix it yourself (and you might not even know it's broken!).

Overall, were I to use Parse again (unlikely), I'd probably stick with giant denormalised objects.

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

3 Comments

Why are you unlikely to use Parse again? Any better recommendation? I only want to use it because it simplifies storage a great deal!
I just found it to cause me more problems than it solved over (e.g.) a naive Rails or Go data store backend. I suspect we were pushing up hard against the intended usage style; i.e. we used it for real time chat, and hosting a non-trivial Angular app. Were also didn't want to 100% buy into the Parse SDK for everything, as it means rewriting the entire application in the event you want to change your data store; abstracting it out was a bit of a pain. Overall, it's not bad per se, but I didn't find it added value versus the complexity in the end.
Thanks Adam very insightful. Will consider the dependencies.
1

Here is a solution to handle two table by the help of userId.

Note- You are creating a table of REGISTRATION and filling few data by your end(code). so you can create an other one table for Address. and when you will create a new table of Address a question will arise that how you manage these table so its simple here you have same user id for both table "REGISTRATION & ADDRESS" then by the help of that unique "userid" you can play. And as per your requirement find
the detail of both table and merge as well.

Hope it will resolve your problem .

Comments

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.