data-modeling

Model design: Users have friends which are users

心已入冬 提交于 2019-12-06 04:02:51
问题 I'm looking to make sure my methods are correct before pursuing this association. The implementation sounds too complicated, so I think there must be something wrong with my plan. I am using structured (SQL) data storage, conforming to the rails storage conventions. What I have is a User model, it has an email address, password_digest , and name in the Schema. class User < ActiveRecord::Base has_many :posts end I'd like to implement a has_many association to a friends collection, so that

What data modeling tools are nosql (couchdb) developers using? [closed]

别说谁变了你拦得住时间么 提交于 2019-12-06 03:45:25
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . At some point, I assume that anyone developing for couchdb (or other nosql option) must still identify what must be stored in each document. And it would seem that, although very rarely, every once in a while we would need to have some relationships between these documents. So, are people still using ER-type software (like Workbench for instance) to create a visual representation of the data stored in the

how to convert YANG data model to JSON data?

柔情痞子 提交于 2019-12-06 03:39:54
How do I convert "YANG" data model to "JSON"? As there is many many docs available in web, in that they changed in YANG synatx to JSON but how the value for the leaf or leaf list they are getting? from where and how it will get actual data in JSON from YANG? user3283069 Convert yang to xml using pyang -f yin filename Convert xml file to json using any of the solutions below https://stackoverflow.com/a/10201397/3283069 https://stackoverflow.com/a/6465496/3283069 Yang is a modeling language, not a data generation language. What you are asking for is a simulator that will contain the same or

Shopping cart and different kinds of discounts. Storing discounts in DB and applying it to order calculations

ぃ、小莉子 提交于 2019-12-06 02:34:32
Currently, I'm looking for best practice to "applying discounts" to cart/order. So, I'm planning to implement such kind of discounts as... fixed user's discount (for example, I'd like to give 10% discount to my favourite customer) discount for number of items (for example, you're buying 10 different colored pens and you'll be getting discount of 1.5%) discount for coupon (for example, during promo action we've produced 100 coupons with 10% discount each. Coupons work only for one order and expire on yyyy-mm-dd) present for purchasing item or group of items (for example, you're buying pen, list

Sequelize.js join table twice using hasMany

不想你离开。 提交于 2019-12-05 22:30:02
I am using Sequelize.js to do a double join on the same table. I have a set of Team objects and a set of Game objects. A team hasMany Games, so it would have foreign keys in the game table, but there are two teams in every game so i need to join the table twice. What is the best way to do this using the sequelize ORM. Team = sequelize.define('teams',{ name : Sequelize.STRING, location : Sequelize.STRING, }); Game = sequelize.define('games',{ homeTeamId : Sequelize.INTEGER, awayTeamId : Sequelize.INTEGER, location : Sequelize.STRING, }); // Associations Game.hasOne(Team, {foreignKey :

Chat, conversation, messaging - CoreData model

浪尽此生 提交于 2019-12-05 20:24:48
Before you mark a question as a duplicate of this question please read a description. I don't need to continue discussion there in the comment. So I want to create CoreData model for messaging app. Like said in this topic did i mentioned - i've had three entities: User entity define a author of message and participant in a conversation. Message entity define every text sending with app. Conversation entity defines conversation beetwen users using messages. OK so my data model is like: But everything is connected to each other here. The only difference between mentioned answer and my solution

Using categorical data as features in sklean LogisticRegression

我的未来我决定 提交于 2019-12-05 17:49:21
问题 I'm trying to understand how to use categorical data as features in sklearn.linear_model 's LogisticRegression . I understand of course I need to encode it. What I don't understand is how to pass the encoded feature to the Logistic regression so it's processed as a categorical feature, and not interpreting the int value it got when encoding as a standard quantifiable feature. (Less important) Can somebody explain the difference between using preprocessing.LabelEncoder() , DictVectorizer

How to update a model's “updated_at” field only for a subset of column updates?

旧时模样 提交于 2019-12-05 16:09:37
There is a typical blog application. Each user has_many posts. Each post has_many tags. I'm sorting each post by updated_at so the most recently updated post will show up on top. So for example, if I update a post's content, the post will come up to the top. However, this also happens when I just add a tag, since a tag is connected to its corresponding post. I only want the content update to change updated_at field. I don't want updated_at for a post to be changed because I added a tag. Is there a way to do this? Or any other way to achieve something like this? Thank you! Two approaches spring

How to model process and status history in a data warehouse?

…衆ロ難τιáo~ 提交于 2019-12-05 15:56:10
Let's say that we have D_PROCESS , D_WORKER and D_STATUS as dimensions, and the fact F_EVENT that links a process (what) with a worker (who's in charge) and the "current" status. The process status changes over time. Shoud we store in F_EVENT one line per process/status/worker, or one line per process/worker, and "somewhere else" one line per status change for a given process/worker? I'm new to Datawarehouse and it's hard to find best practices/tutorial related to data modelization. Read The Data Warehouse Toolkit by Ralph Kimball for a good introduction to dimensional modeling. It sounds like

How to enforce uniques across multiple tables

陌路散爱 提交于 2019-12-05 11:44:18
I have the following tables in MySQL server: Companies: - UID (unique) - NAME - other relevant data Offices: - UID (unique) - CompanyID - ExternalID - other data Employees: - UID (unique) - OfficeID - ExternalID - other data In each one of them the UID is unique identifier, created by the database. There are foreign keys to ensure the links between Employee -> Office -> Company on the UID. The ExternalID fields in Offices and Employees is the ID provided to my application by the Company (my client(s) actually). The clients does not have (and do not care) about my own IDs, and all the data my