database-design

Two Way Embedding vs. One Way Embedding in MongoDB (Many-To-Many)

守給你的承諾、 提交于 2021-02-10 12:13:27
问题 I would like to discuss with you, if it makes any sense to use two way embedding instead of one way embedding, when modeling an N:M relationship in MongoDB. Let's say, we have two entities: A Product can belong to many (few) Categories , and a Category can have many (lots of) Products . Two Way Embedding If we use this approach, our categories would look like this: { _id: 1, name: "Baby", products: [2] } { _id: 2, name: "Electronics", products: [1, 2] } And products : { _id: 1, name: "HDMI

How do I write a function to compare and rank many sets of boolean (true/false) answers?

心已入冬 提交于 2021-02-08 17:12:06
问题 I've embarked on a project that is proving considerably more complicated than I'd first imagined. I'm trying to plan a system that is based around boolean (true/false) questions and answers. Users on the system can answer any questions from a large set of boolean (true/false) questions and be presented with a list showing the most similar users (in order of similarity) based on their answers. I've Googled far and wide but still not come up with much, so I was hoping somebody could point me in

How do I write a function to compare and rank many sets of boolean (true/false) answers?

帅比萌擦擦* 提交于 2021-02-08 17:02:00
问题 I've embarked on a project that is proving considerably more complicated than I'd first imagined. I'm trying to plan a system that is based around boolean (true/false) questions and answers. Users on the system can answer any questions from a large set of boolean (true/false) questions and be presented with a list showing the most similar users (in order of similarity) based on their answers. I've Googled far and wide but still not come up with much, so I was hoping somebody could point me in

Is naming tables september_2010 acceptable and efficient for large data sets dependent on time?

三世轮回 提交于 2021-02-08 12:49:33
问题 I need to store about 73,200 records per day consisting of 3 points of data: id, date, and integer. Some members of my team suggest creating tables using month's as the table name (september_2010), while others are suggesting having one table with lots of data in it... Any suggestions on how to deal with this amount of data? Thanks. ========== Thank you to all the feedback. 回答1: I recommend against that. I call this antipattern Metadata Tribbles . It creates multiple problems: You need to

Notification System Design

杀马特。学长 韩版系。学妹 提交于 2021-02-08 11:49:17
问题 Given the schema below, how can a notification system be incorporated? Users need to be notified when someone comments on their Picture or SaleItem along with when someone makes a bid on their SaleItem (through Purchase Offer). The ultimate goal is to have a notification system that will handle SMS, Email, and an internal system messaging system. The complexities of those options will be worked out but I need the basic data model from which they can be built upon. MySql is the DB being used

Adding constraints that check a separate (linked) table for a value

不打扰是莪最后的温柔 提交于 2021-02-08 11:33:31
问题 I have two tables: Book(BookID, Title, Author, Decision) BookShipment(BookID, ShipmentID) CREATE TABLE BookShipment( BookID CHAR(4), ShipmentID(7) CONSTRAINT pk_BookShipment PRIMARY KEY (BookID, ShipmentID), CONSTRAINT fk_BookShipment_Book FOREIGN KEY (BookID) REFERENCES Book(BookID)); The idea is that a Book needs to be "Approved" before it's added to a Shipment. If it's "Rejected" it won't be added. Is there a way to add an additional constraint to BookShipment that, when a new BookID is

Loops and traps in database design

僤鯓⒐⒋嵵緔 提交于 2021-02-08 10:48:30
问题 I have started working on designing a database in MariaDB in a company. This is first time I am working on it. ( Previously I used to work for Business Objects in Datawarehousing ) However I have created the tables and have joined them as per requirements. I encounter loops, chasm traps and fan traps in the layout which I have created. Do I need to resolve them before working on the database ?? All the search I am doing in the internet about these problems fetches results which are about

Loops and traps in database design

半腔热情 提交于 2021-02-08 10:47:24
问题 I have started working on designing a database in MariaDB in a company. This is first time I am working on it. ( Previously I used to work for Business Objects in Datawarehousing ) However I have created the tables and have joined them as per requirements. I encounter loops, chasm traps and fan traps in the layout which I have created. Do I need to resolve them before working on the database ?? All the search I am doing in the internet about these problems fetches results which are about

database structure for bidding site

拥有回忆 提交于 2021-02-08 10:38:49
问题 I have two tables: items bids -id (pk) -id (pk) -user_id (fk) -user_id (fk) references users (pk) -title -item_id (fk) references items -bid_price I also want the option for user to accept the bid. How should I structure the database to have this facility. Option 1: bids -id (pk) -user_id -item_id -bid_price -is_accepted Option 2: items -id .... -accepted_bid_id (fk references bid) Which option should I take or suggest me other options ? 回答1: If there is only one accepted bid per item, Option

database structure for bidding site

荒凉一梦 提交于 2021-02-08 10:37:26
问题 I have two tables: items bids -id (pk) -id (pk) -user_id (fk) -user_id (fk) references users (pk) -title -item_id (fk) references items -bid_price I also want the option for user to accept the bid. How should I structure the database to have this facility. Option 1: bids -id (pk) -user_id -item_id -bid_price -is_accepted Option 2: items -id .... -accepted_bid_id (fk references bid) Which option should I take or suggest me other options ? 回答1: If there is only one accepted bid per item, Option