denormalization

PostgreSQL join to denormalize a table with generate_series

只愿长相守 提交于 2019-12-10 17:53:50
问题 I've this table: CREATE TABLE "mytable" ( name text, count integer ); INSERT INTO mytable VALUES ('john', 4),('mark',2),('albert',3); and I would like "denormlize" the rows in this way: SELECT name FROM mytable JOIN generate_series(1,4) tmp(a) ON (a<=count) so I've a number of rows for each name equals to the count column: I've 4 rows with john, 2 with mark and 3 with albert. But i can't use the generate_series() function if I don't know the highest count (in this case 4). There is a way to

Denormalization with Mongoose: How to synchronize changes

岁酱吖の 提交于 2019-12-10 02:39:48
问题 What is the best way to propagate updates when you have a denormalized Schema? Should it be all done in the same function? I have a schema like so: var Authors = new Schema({ ... name: {type: String, required:true}, period: {type: Schema.Types.ObjectId, ref:'Periods'}, quotes: [{type: Schema.Types.ObjectId, ref: 'Quotes'}] active: Boolean, ... }) Then: var Periods = new Schema({ ... name: {type: String, required:true}, authors: [{type: Schema.Types.ObjectId, ref:'Authors'}], active: Boolean,

Unique constraint over multiple tables

孤者浪人 提交于 2019-12-09 16:24:11
问题 Let's say we have these tables: CREATE TABLE A ( id SERIAL NOT NULL PRIMARY KEY ); CREATE TABLE B ( id SERIAL NOT NULL PRIMARY KEY ); CREATE TABLE Parent ( id SERIAL NOT NULL PRIMARY KEY, aId INTEGER NOT NULL REFERENCES A (id), bId INTEGER NOT NULL REFERENCES B (id), UNIQUE(aId, bId) ); CREATE TABLE Child ( parentId INTEGER NOT NULL REFERENCES Parent (id), createdOn TIMESTAMP NOT NULL ); Is it possible to create a unique constraint on Child such that for all rows in Child at most one

Structuring Relationships in Firebase

三世轮回 提交于 2019-12-07 03:02:36
问题 I've got two items in my Firebase: providers and services , and I'm trying to figure out the best way to structure and build relationships using Firebase's recommended flattened architecture approach. My data looks something like this: { "services" : { "hip_replacement" : { "title" : "Hip Replacement" } }, "providers" : { "the_blue_hospital" : { "title" : "The Blue Hospital" } } } I would like to link these two items together so that if you were to visit the Hip Replacement page, The Blue

Are Denormalized Updates Possible With NHibernate Without Using a Stored Procedure?

爱⌒轻易说出口 提交于 2019-12-06 12:51:18
问题 I'm pondering the use of NHibernate on a project that has a database with some degree of planned denormalization (planned by the DBAs). Reading from one set of tables and mapping one column to one property is not a problem. However when updating I'd have to map one property back to the original column in the original table plus update a few copies of that column in the denormalized tables. Is it possible to do this with NHibernate without using stored procedures? EDIT: Although I tend to

Safely normalizing data via SQL query

回眸只為那壹抹淺笑 提交于 2019-12-06 04:59:18
问题 Suppose I have a table of customers: CREATE TABLE customers ( customer_number INTEGER, customer_name VARCHAR(...), customer_address VARCHAR(...) ) This table does not have a primary key. However, customer_name and customer_address should be unique for any given customer_number . It is not uncommon for this table to contain many duplicate customers. To get around this duplication, the following query is used to isolate only the unique customers: SELECT DISTINCT customer_number, customer_name,

Logstash -> Elasticsearch - update denormalized data

筅森魡賤 提交于 2019-12-06 03:31:24
问题 Use case explanation We have a relational database with data about our day-to-day operations. The goal is to allow users to search the important data with a full-text search engine. The data is normalized and thus not in the best form to make full-text queries, so the idea was to denormalize a subset of the data and copy it in real-time to Elasticsearch, which allows us to create a fast and accurate search application. We already have a system in place that enables Event Sourcing of our

Should I use flat tables or a normalized database?

我与影子孤独终老i 提交于 2019-12-05 12:18:00
问题 I have a web application that I am currently working on that uses a MySQL database for the back-end, and I need to know what is better for my situation before I continue any further. Simply put, in this application users will be able to construct their own forms with any number fields (they decide) and right now I have it all stored in a couple tables linked by foreign keys. A friend of mine suggests that to keep things "easy/fast" that I should convert each user's form to a flat table so

Structuring Relationships in Firebase

孤人 提交于 2019-12-05 07:12:35
I've got two items in my Firebase: providers and services , and I'm trying to figure out the best way to structure and build relationships using Firebase's recommended flattened architecture approach. My data looks something like this: { "services" : { "hip_replacement" : { "title" : "Hip Replacement" } }, "providers" : { "the_blue_hospital" : { "title" : "The Blue Hospital" } } } I would like to link these two items together so that if you were to visit the Hip Replacement page, The Blue Hospital would show up underneath it, if you were to visit The Blue Hospital page, Hip Replacement would

Are Denormalized Updates Possible With NHibernate Without Using a Stored Procedure?

大城市里の小女人 提交于 2019-12-04 19:18:54
I'm pondering the use of NHibernate on a project that has a database with some degree of planned denormalization (planned by the DBAs). Reading from one set of tables and mapping one column to one property is not a problem. However when updating I'd have to map one property back to the original column in the original table plus update a few copies of that column in the denormalized tables. Is it possible to do this with NHibernate without using stored procedures? EDIT: Although I tend to agree with NXC's answer, this question is about how to solve the problem with NHibernate as opposed to