database-design

How many rows to insert per notification in a notification system?

拜拜、爱过 提交于 2021-02-07 08:50:37
问题 Following on from this question I am looking at building a similar notification system and I have a question (which has an obvious answer I think but I'd prefer to have some other opinions): If a particular post generated a million likes, and then someone adds a comment to that post, I would need to notify those million people who liked the post about the comment that was added. Is the only way to achieve this to write a million rows into a NotificationRead table which has the NotificationID

How many rows to insert per notification in a notification system?

不打扰是莪最后的温柔 提交于 2021-02-07 08:49:25
问题 Following on from this question I am looking at building a similar notification system and I have a question (which has an obvious answer I think but I'd prefer to have some other opinions): If a particular post generated a million likes, and then someone adds a comment to that post, I would need to notify those million people who liked the post about the comment that was added. Is the only way to achieve this to write a million rows into a NotificationRead table which has the NotificationID

How does Facebook do it?

落爺英雄遲暮 提交于 2021-02-07 08:13:26
问题 Have you ever noticed how facebook says “3 friends and 33 others liked this”? I was wondering what the best approach to do this is. I don’t think going through the friends list, and the list of users who “liked this” and comparing them is efficient at all! Do they keep a track of this in the database? That will make the database size very huge. What do you guys think? Thanks! 回答1: I would guess they outer join their friends table with their likes table to count both regular likes and friend

How to store opening weekdays in a database

天大地大妈咪最大 提交于 2021-02-07 07:19:17
问题 I have a group of checkboxes where the user selects some of the weekdays (the opening days of a store). How can I save the selected days? Should I save something like 0111111 (zero means closed on sunday) on the same field and split the result when reading the data? Or create a field for each day and store 0 or 1 on each (weird)? 回答1: The first approach saves space, the second improves performance while retrieving data, especially if you need to filter by individual weekday. It also makes the

Determining row changes since last access in SQL Server

纵然是瞬间 提交于 2021-02-07 03:42:46
问题 We have a multiuser system with users saving to a central SQL Server 2005 database. We have encountered an issue where a user refreshes in changes from the db while another user saves new data. The way we are currently collecting the changes is we have a timestamp column on each table which is filled at every row insert/update. Another user will have a timestamp stored on the client which is the last time he did a pull from the database. Each save is done in a transaction. The example we are

Determining row changes since last access in SQL Server

不打扰是莪最后的温柔 提交于 2021-02-07 03:41:24
问题 We have a multiuser system with users saving to a central SQL Server 2005 database. We have encountered an issue where a user refreshes in changes from the db while another user saves new data. The way we are currently collecting the changes is we have a timestamp column on each table which is filled at every row insert/update. Another user will have a timestamp stored on the client which is the last time he did a pull from the database. Each save is done in a transaction. The example we are

Entity Framework and multi-tenancy database design

余生长醉 提交于 2021-02-06 11:27:16
问题 I am looking at multi-tenancy database schema design for an SaaS concept. It will be ASP.NET MVC -> EF, but that isn't so important. Below you can see an example database schema (the Tenant being the Company). The CompanyId is replicated throughout the schema and the primary key has been placed on both the natural key, plus the tenant Id. Plugging this schema into the Entity Framework gives the following errors when I add the tables into the Entity Model file (Model1.edmx): The relationship

Entity Framework and multi-tenancy database design

青春壹個敷衍的年華 提交于 2021-02-06 11:24:40
问题 I am looking at multi-tenancy database schema design for an SaaS concept. It will be ASP.NET MVC -> EF, but that isn't so important. Below you can see an example database schema (the Tenant being the Company). The CompanyId is replicated throughout the schema and the primary key has been placed on both the natural key, plus the tenant Id. Plugging this schema into the Entity Framework gives the following errors when I add the tables into the Entity Model file (Model1.edmx): The relationship

Creating and Bridge tables in MySQL query

萝らか妹 提交于 2021-02-04 19:26:28
问题 I am working with a basic table design for a MySQL database. This database project was given as an idea, mainly aimed for an educational purpose. There are a total of 11 tables which 2 are used for bridging purposes. I tried to properly set primary and foreign keys. I am not sure how to write the query that will create the 11 tables and bridge them all at once. HERE I have attached a visual diagram of these tables. Through basic learning I can create one table but not sure how to advance from

SQL database relationships: unable to determine between manyToMany and oneToMany

Deadly 提交于 2021-01-29 18:34:48
问题 I have two database tables "Users" and "Transactions" where the "Transactions" table looks like below. The "Transactions" table has a record of each transaction between two accounts where the differentiator is "senderAccount" and "recipientAccount" columns. id | transactionId | senderAccount | recipientAccount | Amount | —--+---------------+---------------+------------------+--------+ 1 | ijiej33 | A | B | 100 | The relationship between "Users" and "Transactions" is one to many since every