data-modeling

Should these be 3 SQL tables or one?

瘦欲@ 提交于 2019-12-11 05:33:10
问题 This is a new question which arose out of this question Due to answers, the nature of the question changed, so I think posting a new one is ok(?). You can see my original DB design below. I have 3 tables, and now I need a query to get all the records for a specific user for running_balances calculations. Transactions are between users, like mutual credit. So units get swapped between users. Inventarizations are physical stuff brought into the system; a user gets units for this. Consumations

What would it mean If I change the identifying relationship from this part of a database design to a non-identifying relationship?

£可爱£侵袭症+ 提交于 2019-12-11 04:20:13
问题 I have a question regarding this database design. I am a bit unsure of the difference between identifying and non-identifying relationships in a database leading me to some puzzles in my head. I have this database design: (kind of like a movie rental stores. "friend" are those who borrow the movie. "studio" is the production studios that collaborated in making the movie.) I somewhat understand how it works. However, I was wondering what if I create a loan_id in the loan table, and use movie

Slowly changing dimension - What is Pure type 6 implementation

孤者浪人 提交于 2019-12-11 04:07:55
问题 I am trying to understand pure type 6 SCD implementation from WIKI which says mainly three points Having a Type 2 surrogate key for each time slice can cause problems if the dimension is subject to change. A pure Type 6 implementation does not use this, but uses a Surrogate Key for each master data item (e.g. each unique supplier has a single surrogate key). This avoids any changes in the master data having an impact on the existing transaction data. However I am unable to visualize these

Run linear model in a powerset of variables

人盡茶涼 提交于 2019-12-11 03:56:00
问题 I am trying to get a data frame with different variables and run a linear model for each combination of those variables. A simple example is: names <- c("Var1", "Var2", "Var3") vars <- ggm::powerset(names, sort = T, nonempty = T) The powerset function gives me all the combinations of the 3 variables -- a list with 7 elements, each element is of type character. (the actual code I am trying to run has 16 variables, that's why I don´t want to manually write each of the models). What I would like

Google App Engine ndb: find the position of an order query list

江枫思渺然 提交于 2019-12-11 03:38:49
问题 On Google App Engine's ndb, I used the following to retrieve all entities and sort them according to their grade: ranks = Member.query().order(-Member.grade) Then I would like to know the position of a specific member: i = 0 for rank in ranks: if rank.account == 'abc' position = i break i += 1 My question: is there an equivalent ndb operation to find the position of a specific entity? Thanks. 回答1: I believe it could be done in two steps Retrieve the entry whose account is 'abc' target =

Core Data Model Design - Changing “Live” Objects also Changes Saved Objects

我只是一个虾纸丫 提交于 2019-12-11 03:21:44
问题 I'm working on my first Core Data project (on iPhone) and am really liking it. Core Data is cool stuff. I am, however, running into a design difficulty that I'm not sure how to solve, although I imagine it's a fairly common situation. It concerns the data model. For the sake of clarity, I'll use an imaginary football game app as an example to illustrate my question. Say that there are NSMO's called Downs and Plays. Plays function like templates to be used by Downs. The user creates Plays (for

How do I store unsigned integers in Cassandra?

半腔热情 提交于 2019-12-11 02:24:37
问题 I am storing some data in Cassandra via the Datastax driver, and I have the need to store unsigned 16-bit and 32-bit integers. For unsigned 16-bit integers, I can easily store them as signed 32-bit integers and cast them as needed. For unsigned 64-bit integers, however, I am at a loss. I can store them as strings and parse them, or I can store them as byte arrays. I could store them as 64-bit signed integers and do the bit manipulation required to convert from and to 64-bit unsigned integers.

MySQL Data Model to Cassandra Help?

血红的双手。 提交于 2019-12-10 23:15:50
问题 I'm trying to move a RDBMS model over to Cassandra, and having a hard time creating the schema. Here is my data model: CREATE TABLE Domain ( ID INT NOT NULL PRIMARY KEY, DomainName NVARCHAR(74) NOT NULL, HasBadWords BIT, ... ); INSERT INTO Domain (DomainName, HasBadWords) VALUES ('domain1.com', 0); INSERT INTO Domain (DomainName, HasBadWords) VALUES ('domain2.com', 0); CREATE TABLE ZoneFile ( ID INT NOT NULL PRIMARY KEY, DomainID INT NOT NULL, Available BIT NOT NULL, Nameservers NVARCHAR(MAX)

implementing UNIQUE across linked tables in MySQL

蹲街弑〆低调 提交于 2019-12-10 20:03:52
问题 a USER is a PERSON and a PERSON has a COMPANY - user -> person is one-to-one, person -> company is many-to-one. person_id is FK in USER table. company_id is FK in PERSON table. A PERSON may not be a USER, but a USER is always a PERSON. If company_id was in user table, I could create a unique key based on username and company_id, but it isn't, and would be a duplication of data if it was. Currently, I'm implementing the unique username/company ID rule in the RoseDB manager wrapper code, but it

Data Modeling 3 Way Table has_many association

匆匆过客 提交于 2019-12-10 14:05:42
问题 I am attempting to build a table to handle both the location and category a certain campaign has been set to with the following model associations: class Campaign < ActiveRecord::Base has_many :campaign_category_metro_bids, dependent: :destroy has_many :metros, through: :campaign_category_metro_bids has_many :categories, through: :campaign_category_metro_bids end class Metro < ActiveRecord::Base has_many :campaign_category_metro_bids has_many :campaigns, through: :campaign_category_metro_bids