database-design

transaction handling : How are simultaneous transaction managed?

佐手、 提交于 2019-12-21 23:54:08
问题 Suppose a withdrawal transaction of 6000 is happening on account ABC(fund:1000) and at the same time a withdrawl of 8000 is carried out from ATM. Then how will the transaction be managed. Will the database open just one connection and doesnt allow new connection to the same account ?? .... What will happen in such cases when a transaction needs to be done on same account simultaneously and how are these things managed. 回答1: This is a good question on a very complex topic. There's a technical

Getting list of all posts with user like and total likes for each post in firestore

荒凉一梦 提交于 2019-12-21 23:14:24
问题 This question is related to querying firestore and best approach for implementing like system and counting no of likes for each post in firestore . Let us say we have collection called posts, likes, comments, hashtags. Which has json structure like this. posts:[{ likes [{ postId:id postId:, createdAt:date userId, title:string, collectionType:'posts', description,string likedAt:date updatedAt,date }] createdUser:userId updatedUser:userId, }] comments:[{ hashtags [{}] postId, userComments:[{

Keeping one table or multiple table for similar type of data which one is best while considering high performance

帅比萌擦擦* 提交于 2019-12-21 23:01:06
问题 I am designing DATABASE for a Sales and Purchase application like ERP and using MYSQL as RDBMS, I have doubt on creating table for sales and purchase entities to go with single table for each module(Sale/Purchase) or multiple tables for each entities(Sales order, Sale invoice, Sale return, Purchase order, Purchase invoice, Purchase return) in longer run. Below is my use case. My application will have Sale Order, Sale Delivery, Sale Invoice, Sale Return and Credit Note and same entity for

best practice data design in firebase

做~自己de王妃 提交于 2019-12-21 21:39:33
问题 How could i structure data for following scenario? There is an app called Food Ordering System. It contains Username(Who is registering this restaurant menus for online order) Restaurant_name Description Location Estimated Delivery Menu(Has multiple menus for one restaurant) My design "restaurant":{ "username":{ "restaurant_name":"KFC Restaurant", "description":"short description on restaurant", "estimated delivery":"1hour/km", "distance":"20km away", "location":"Kathmandu", "rating":"rating

Replace multiple joins in SQL with CouchDB views

一笑奈何 提交于 2019-12-21 21:33:19
问题 I am implementing a filter feature for my application and having trouble with writing the view on CouchDB. While in SQL, this would be a statement with multiple join. How to replace multiple join in CouchDB. This article covers single join: http://www.cmlenz.net/archives/2007/10/couchdb-joins. However, it's not obvious to me how to extend this approach to multiple join. Imagine my object has a dozen properties and each property can have its individual filter. For simplicity, let's assume it

Database design - exposing Primary Key

老子叫甜甜 提交于 2019-12-21 21:32:48
问题 Imagine that I have a Customer table. And in this table is an ID column, Primary Key int, Identity, all that jazz. Our Customer also has a Name. Now, if I was to send out information in a report, or an e-mail blast, where there was a link back into my website to uniquely identify that Customer, would it be good practice to use the Primary Key ID field? All my instincts are telling me this is awful, and that surrogate IDs should PURELY be used for the database only - and never exposed to the

ERD - How to model a relation between two entites with a third entity as “attribute”

大兔子大兔子 提交于 2019-12-21 20:44:13
问题 I'm modeling an entity relationship diagram and got stuck. I'm not sure if my considerations are wrong or an ERD can't modell what I want: I have three entities: Employee, Project and Role. There is a relation between Employee and Project: an employee is working on a project. But this employee isn't just working on this project, he/she has a field of operation that is given as a role. But isn't a relation just described by attributes? How can I make something like "An employee works on this

Why are there “relations” on databases instead of just using SQL's join?

孤街浪徒 提交于 2019-12-21 20:39:55
问题 I always see in database articles or tutorials or... just everywhere where they use databases, they use a thing called relations. It comes to my mind instantaneously those little boxes with lists of field names and one field connected to another field in another box with a line. I'm not an expert on databases (as you can probably tell) but the little bit I've used, I never needed relations. They always seemed to be redundant as I can always use JOIN to achieved what it seemed to me they are

Structuring a recipe database

霸气de小男生 提交于 2019-12-21 20:28:56
问题 I'm working on building a database that will search for recipes by ingredients. For example, I think I plan on populating the database with types of ingredients that are accepted, but I don't want to have to parse the string which includes all the ingredients in a particular recipe. I was thinking of making just like an list of acceptable ingredients table and searching through that somehow to see if it exists or not. I feel like this will be a very taxing operating though, and I want this to

SQL constraint to check whether value doesn't exist in another table

有些话、适合烂在心里 提交于 2019-12-21 20:23:06
问题 In my PostgreSQL 9.4 database, I have a table fields with a column name with unique values. I'm creating a new table fields_new with a similar structure (not important here) and a column name as well. I need a way to constraint name values to be inserted to the fields_new not to be present in fields.name . For example, if fields.name contains the values 'color' and 'length' , I need to prevent fields_new.name from containing 'color' or 'length' values. So, in other words I need to provide