I am building a platform where users can rate a musicians song. I have been using AWS mobile which only builds in dynamodb but no relational databases.
I am just wondering whether is is possible to use a nosql database for the song rating purpose.
I can see that i would have a table for songs and for each song I could have a large number of votes but then how would I go about giving ownership of that vote to the user.
Thanks
Related
I am looking to build a scalable real-time chat app (I am just doing this for fun and out of interest so please don't ask why!) and I know that I am going to be handling the realtime messaging part through redis but I am not sure of what database to use for the following information:
User Relationships (friends)
Cold Chat History - this would only be queried in limited amounts (maybe like 50 messages) ordered by timestamp and queried in reverse (just as your messages would load in imessage or whatsapp when scrolling to view older messages)
Chat user relationship
I know for cold chat history an RDBMS or Cassandra is probably my best bet but handling friend relationships, as well as user-to-chat relationships in an RDBMS or cassandra, is ugly. I'm not sure if it's necessary, worth it, or even "right" to have a graph database in my tech stack just for this relationship mapping.
I was thinking of MongoDB or some other document-based storage could be a solution but querying the data seems like it would be really taxing. My thoughts were to have a chat document that has a list of users and then I would have several other documents with a list of message id's pointing to message documents. These documents would be mapped back to the chatID. I'm sure you can see though, the time and resources to query a set of messages would be quite high. Maybe I'm just underestimating the power of MongoDB as I haven't really used it. I would also be more easily able to handle the Chat User Relationship using documents as well as friendships by just storing user-ids in a list within the document.
I understand there is no perfect tool for the job but I would like someone's thoughts and inputs on how to design the data storage.
Thank you in advance!
If transaction volume is not high then you can go with Postgresql otherwise Cassandra is a good choice for all your mentioned requirements.
In Cassandra you should have multiple tables in de-normalized for low latency and high availability.
User - Create a master table having all information of any user.
User_Friend_relation - Create another table having composite primary key as userid & freindid with clustering key is_active(0,1) desc. ((userid,freindid),is_active)
Chat_user_friend - This is your main table having all chat. Create this table with timestamp as clustering key and store data in desc order so that you can save time by ordering in real time and you have latest data first.
Cold Chat History - As Cassandra is highly scalable... no need of this table.
Data modeling is an area where a lot of discussions are required, anyways I tried to answer this as simple as possible.
It's best to keep relationship in realtional database.
I use PostgreSQL for such purposes in my chat applications.
For chat history and other events Cassandra is a good choice (I also use Cassandra). However it depends on your database size (records quantity). If you don't need to keep tens of thousands historical messages for thousands users then using Cassandra will be an overkill. In this case you can also use PostgreSQL or another relational database.
In PostgreSQL you can optimize an access to history tables using partitioning.
Assuming a e commerce web app has a high amount of requests, how do I prevent two users from choosing the only product left? Should I check the quantity when adding to shopping list or payment? Is it using a field to record quantity of selected product in DB is bad way? How does the large e commerce web app like amazon deal with conflict problem?
Several options that I know :
For the RDBMS that support ACID , you can use optimistic locking technique on the product table. Unless it is very often that many users hit the buying button on the same product at the nearly same times ,it should work pretty well.(For how many users does the 'many' means, you have to measure it. I think 1k should be no problem. Just my guess , don't take it for granted)
Do not check it and let users to buy it. Adjust the business flow to handle it. For example, when an user hits the buying button ,tell him his order is just accepted and will be processed but not guarantee he must able to buy it. Then in the later stage when you find that there is not enough inventory to ship the product to him , send an email to apologise and refund to him.
Also in the real business , it is common that the product inventory can go to negative and still accepting orders but tell the user he will get the product at XXX days later. The business can then produce or order more product from the supplier after receiving the money.
If you are buying iPhone on the Apple web site , it also works like this.
It really depends upon the number of concurrent users here. In the case of millions, the NoSQL approach is prefered to manage the basket with eventual consistency then the buying process would go with ACID to ensure the product can be sold.
For less users, you can rely on an ACID database.
If you are not sure, you may go with a database that has ACID capabilities but can as well allow you to work in an eventual consistency way or that can implement the concept of sharding for scalability purpose. To my knowledge Oracle can do these 3 things: COMMIT NO WAIT, COMMIT and Sharding deployment.
HTH
I need to create a big database where I've a lot of user end every user can store a million of row in a DB, My question is, I can make (In rails) one system where every user have a own DB ? for example one general DB where i can store the user and a lot of db where the user can store the data, or isn't good for the speed of my rails app ?
You can use Postgre Schemas for each user.
http://www.postgresql.org/docs/9.0/static/ddl-schemas.html
It's common used for multi-tenancy applications where you have an app created to server a lot of "accounts" where those accounts have a lot of users.
Pretty much they'll have the same tables but the data are separated by schemas.
I'm not sure but in the future you can scale and balance the schemas in different servers.
Here's some approaches on this gem: https://github.com/influitive/apartment
This is the scenario i have:
im developing a web app that will list down all the details of a car that the user picks from a list. I have a database of all car models, makes, sizes, prices etc. Besides i also have the price trend for the past 5 yrs. You may assume that i have a few of such tables and the data volume is about 10s of thousands of records.
My online application should be able to let the user pick his choice of one car model and optionally provide his address. With just this user input, i want to be able to generate a pdf report with the following information:
Comparison of selected car model with other cars manufactured in the same country. (e.g, if user selected, honda, i want to compare it with toyota, which comes from the same country)
Comparion of selected car with other car of similar type (eg. sedan vs sedan)
Price trend of the car for the last 5 yrs - Nearest car workshops in user's neighbourhood within a radius of 10km (if user has given me his address)
i will be drawing out several other data from my database.
I would like to present this report instantly, say within 3 minutes to the user. So now the question, is, what software/tools/program/database etc should i be using, taking in consideration the huge amount of data and the need to present this in the fastest possible time as a pdf report?
There are whole lot of possibilities. You can use PHP (or) Java (or) .Net (or) so on...for web application, MySQL, SQL Server, Oracle etc., as database (If data is really big and grows like anything daily you may consider Hbase also) It dependency on how soon you want your product out in the market and how much scalable it should be and how much comfortable you are with any of those technologies.
Some technologies support nice user interface, some may not but strong in other area of web application.
How much money/time you have for development, licensing also plays role in deciding answer for this question.
I'm new to website design and am building/learning how to put together a data driven website that will help users with calorie/ vegetarian types of queries. My question is for big sites like DailyBurn, SparkPeople do they rent a database or build their own? I know users data is stored on their sites, so do they have separate db's for user input and calorie output? If someone is building their site from scratch is it better and cheaper to just create their own db's from scratch or pay for an existing one?
The other negative is a site like CalorieKing requires me to show their name on any queries I think even for the paid service which I do not want to do.
Thanks
H
They're probably going to be separate tables of the same database.
I'm not exactly sure what you mean by creating your own database, but with the advent of AWS they are dirt cheap.