schema-design

What are the [dis]advantages of using a key/value table over nullable columns or separate tables?

笑着哭i 提交于 2019-12-17 17:29:00
问题 I'm upgrading a payment management system I created a while ago. It currently has one table for each payment type it can accept. It is limited to only being able to pay for one thing, which this upgrade is to alleviate. I've been asking for suggestions as to how I should design it, and I have these basic ideas to work from: Have one table for each payment type, with a few common columns on each. (current design) Coordinate all payments with a central table that takes on the common columns

Using multiple PostgreSQL schemas with Rails models

柔情痞子 提交于 2019-12-17 17:25:40
问题 I have a PostgreSQL database for my Rails application. In the schema named 'public' the main Rails models tables are stored etc. I have created a 'discogs' schema which will have tables with names that are sometimes the same as in the 'public' schema - which is one of the reasons that I'm using schemas to organize this. How would I setup models from the 'discogs' schema in my app? I will be using Sunspot to let Solr index these models as well. I'm unsure of how you would do this. 回答1:

Best schema design for table relationship that enforces integrity

久未见 提交于 2019-12-13 12:06:39
问题 Given a table of models 'A', that can have multiple child models 'B', of which 'B' will have one or more child models 'C'.. this sounds simple, however I need to enforce that for each 'A', any 'B' must have a unique collection of 'C'.. for example, C cannot be a child of two 'B's that are part of the same parent 'A'.. but a 'C' can be a child of multiple 'B's given that each 'B's parent 'A' is distinct.. Does that make sense or should I unobfuscate my scenario? cheers in advance! Note that I

References vs embeds in MongoDB

ぃ、小莉子 提交于 2019-12-11 14:19:50
问题 I'm trying to figure out how to best use MongoDB for a very small and simple use case, but finding the docs somewhat confusing. My document should represent the fact that a user can have many emails. If I follow the documentation the most obvious and simple solution is to use embeds. The problem is when I want to validate the email address for uniqueness, which is AFAIK impossible with embeds (of course I can use map/reduce, but it seems a very poor choice). I definitely feel like emails don

Is modifying existing XSD type by extending it from exact same type backward compatible?

雨燕双飞 提交于 2019-12-11 13:45:54
问题 I made earlier XSD+WSDL for a WS that is implemented by a customer. We implement the client. I have type like this in WS Create-operation: <xs:complexType name="tWorkCreate"> <xs:sequence> <xs:element ref="plan:workkey" /> <xs:element ref="plan:workdata" /> </xs:sequence> </xs:complexType> Now I would like to use the same type for new Update-operation, but naming is wrong. So I plan to do like this: <xs:complexType name="tWorkSet"> <xs:sequence> <xs:element ref="plan:workkey" /> <xs:element

Cassandra schema design sorted by time

那年仲夏 提交于 2019-12-10 12:00:03
问题 I'm new on cassandra data modeling, I realy need same advice, here is my problem: I need to create a new column family that will allow me to store and retrieve last inserted scores : CREATE TABLE average_score( audit_time timestamp PRIMARY KEY, pages_count int, score float, ) The inserted data is not sorted according to primary key (i'm using a random partinioner(default)), do you have any solution please ? Can I specify a different partitionner just for this family column ? thanks 回答1: Here

In SQL / MySQL, are there reasons not to put one-to-one relationship in the same table?

倖福魔咒の 提交于 2019-12-10 05:37:10
问题 One-to-one relationship could usually be stored in the same table. Are there reasons not to store them in the same table? 回答1: Number and type of columns. There is a limit on the size of the columns in a table. See here. There is a maximum of 8,060 bytes per row. Very large tables can also affect performance and can be difficult to optimize and index well. This is apart from keeping data the is conceptually different, apart from each other. For example, a country and currency have a 1 to 1

Cross-referencing foreign keys in Django 1.4

风流意气都作罢 提交于 2019-12-08 09:04:31
I have a Django project where I would need two models to have a foreign key to each other. However this is not possible because two Python files would have to import each other which Python doesn't allow. What is the best way to solve this problem? So my code currently looks like this: countries/models.py: from django.db.models import Model, ForeignKey from users.models import Profile class Country(Model): president = ForeignKey(Profile) users/models.py: from django.db.models import Model, ForeignKey from countries.models import Country class Profile(Model): citizenship = ForeignKey(Country)

Mongodb map reduce across 2 collection

旧街凉风 提交于 2019-12-06 07:24:31
Let say we have user and post collection. In post collection, vote store the user name as a key. db.user.insert({name:'a', age:12}); db.user.insert({name:'b', age:12}); db.user.insert({name:'c', age:22}); db.user.insert({name:'d', age:22}); db.post.insert({Title:'Title1', vote:[a]}); db.post.insert({Title:'Title2', vote:[a,b]}); db.post.insert({Title:'Title3', vote:[a,b,c]}); db.post.insert({Title:'Title4', vote:[a,b,c,d]}); We would like to group by the post.Title and find out the count of vote in different user age. > {_id:'Title1', value:{ ages:[{age:12, Count:1},{age:22, Count:0}]} } > {

In SQL / MySQL, are there reasons not to put one-to-one relationship in the same table?

房东的猫 提交于 2019-12-05 11:35:38
One-to-one relationship could usually be stored in the same table. Are there reasons not to store them in the same table? Number and type of columns. There is a limit on the size of the columns in a table. See here . There is a maximum of 8,060 bytes per row. Very large tables can also affect performance and can be difficult to optimize and index well. This is apart from keeping data the is conceptually different, apart from each other. For example, a country and currency have a 1 to 1 relationship (illustrative example, I know this is not always the case). I would still not keep them together