database-design

Do Something When MYSQL Column Value Increments by 100

寵の児 提交于 2021-01-29 18:34:38
问题 I need to alert members of a site when their post count has reached a multiple of 100. Is it possible to run a function or echo something when a value in a mysql table reaches 100, 200, 300, etc? Table structure: username | password | email | posts I'm currently displaying their post count with: $sql = mysql_query("SELECT `posts` FROM `user` WHERE username='$username'") or die(mysql_error()); $row = mysql_fetch_array($sql); echo "<br /><h4>Your posts:</h4>" . " " . $row['posts']; RESOLVED : I

Database messaging for multiple model types - user, group, global

橙三吉。 提交于 2021-01-29 15:04:14
问题 I want to implement an alert messaging system, in a website, that will show a message to either multiple users , multiple groups (different DB representation), or globally to all users. What would a good database relationship for this behavior look like? 回答1: This is where I would start based on the information you've given... A table for the alert messages to be sent out... alerts id unsigned int(P) message text +----+---------------------+ | id | message | +----+---------------------+ | 1 |

MongoDB architecture: how to store a large amount of arrays or sub documents in a scalable way

风流意气都作罢 提交于 2021-01-29 14:56:03
问题 I am currently working on a blogging app, in which users can create their own blogs and each blog has blogposts within that. I'm ideating about architecting a database that is scalable when each blog has a lot of blogposts. So is it better to structure my database as this: blog1 : { blogname : 'blog1', blogposts: [array of blogposts] }, blog2 : { blogname : 'blog2', blogposts: [array of blogposts] } Or should I create a separate collection with all the blogposts, something like this:

Absorbing N in a M:N relationship

人走茶凉 提交于 2021-01-29 03:44:29
问题 I am encountering an issue I am trying to wrap my head around. I am using learnmongodbthehardway as a resource to define my options modelling a M:N relationship. According to this link I have two options: One way embedding and Two way embedding. I’d like to add a third option to this list called absorption. Absorption takes place when it makes no sense to implement one of the entity’s on its own. It might never be queried for example. An example of this can be extracted from the following

Absorbing N in a M:N relationship

旧城冷巷雨未停 提交于 2021-01-29 03:36:05
问题 I am encountering an issue I am trying to wrap my head around. I am using learnmongodbthehardway as a resource to define my options modelling a M:N relationship. According to this link I have two options: One way embedding and Two way embedding. I’d like to add a third option to this list called absorption. Absorption takes place when it makes no sense to implement one of the entity’s on its own. It might never be queried for example. An example of this can be extracted from the following

Storing single form table questions in 1 or multiple tables

蓝咒 提交于 2021-01-28 21:17:35
问题 I have been coding ASP.NET forms inside web applications for a long time now. Generally most web apps have a user that logs in, picks a form to fill out and answers questions so your table looks like this Table: tblInspectionForm Fields: inspectionformid (either autoint or guid) userid (user ID who entered it) datestamp (added, modified, whatever) Question1Answer: boolean (maybe a yes/no) Question2Answer: int (maybe foreign key for sub table 1 with dropdown values) Question3Answer: int

How to represent and query from a three entity relationship in spring boot?

不想你离开。 提交于 2021-01-28 13:33:38
问题 I am developing a mall system where a User can have one or more shops. If you create a shop, you have the role ADMIN for that shop, else: you create an account then you are assigned a shop as a MANAGER by the ADMIN of that shop. A user can have a shop that they are an admin , but as well be a manager to a different shop assigned to you by an owner of a that shop. Thus, i have come up with three entities: User, Role and Shop. User Entity @Entity @Table(name = "us_users") public class User {

How to represent and query from a three entity relationship in spring boot?

假如想象 提交于 2021-01-28 13:32:51
问题 I am developing a mall system where a User can have one or more shops. If you create a shop, you have the role ADMIN for that shop, else: you create an account then you are assigned a shop as a MANAGER by the ADMIN of that shop. A user can have a shop that they are an admin , but as well be a manager to a different shop assigned to you by an owner of a that shop. Thus, i have come up with three entities: User, Role and Shop. User Entity @Entity @Table(name = "us_users") public class User {

Finding the histogram size for a given table PostgreSQL

僤鯓⒐⒋嵵緔 提交于 2021-01-28 11:51:16
问题 I have a PostgreSQL table named census . I have performed the ANALYSE command on the table, and the statistics are recorded in pg_stats . There are other entries in this pg_stats from other database tables as can be expected. However, I wanted to know the space consumed for storing the histogram_bounds for the census table alone. Is there a good and fast way for it? PS: I have tried dumping the pg_stats table onto the disk to measure the memory using select * into copy_table from census where

Finding the histogram size for a given table PostgreSQL

£可爱£侵袭症+ 提交于 2021-01-28 11:40:25
问题 I have a PostgreSQL table named census . I have performed the ANALYSE command on the table, and the statistics are recorded in pg_stats . There are other entries in this pg_stats from other database tables as can be expected. However, I wanted to know the space consumed for storing the histogram_bounds for the census table alone. Is there a good and fast way for it? PS: I have tried dumping the pg_stats table onto the disk to measure the memory using select * into copy_table from census where