data-modeling

Designing 1:1 and 1:m relationships in SQL Server

故事扮演 提交于 2020-01-09 19:10:34
问题 In SQL Server 2008, how does one design a 1:1 and 1:m relationship? 回答1: Any relationship requires that the "parent" table (the one side) have a Primary (or unique) Key (PK), that uniquely identifies each row, and the "child" table (the other side) have a Foreign Key column or columns, that must be populated with values that are the same as some existing value[s] of the Primary Key in the parent table. If you want a one to many (1-M) relationship then the Foreign Key should be an ordinary

Designing 1:1 and 1:m relationships in SQL Server

不问归期 提交于 2020-01-09 19:09:37
问题 In SQL Server 2008, how does one design a 1:1 and 1:m relationship? 回答1: Any relationship requires that the "parent" table (the one side) have a Primary (or unique) Key (PK), that uniquely identifies each row, and the "child" table (the other side) have a Foreign Key column or columns, that must be populated with values that are the same as some existing value[s] of the Primary Key in the parent table. If you want a one to many (1-M) relationship then the Foreign Key should be an ordinary

de-normalizing data model: django/sql -> app engine

与世无争的帅哥 提交于 2020-01-07 02:21:29
问题 I'm just starting to get my head around non-relational databases, so I'd like to ask some help with converting these traditional SQL/django models into Google App Engine model(s). The example is for event listings, where each event has a category, belongs to a venue, and a venue has a number of photos attached to it. In django, I would model the data like this: class Event(models.Model) title = models.CharField() start = models.DatetimeField() category = models.ForeignKey(Category) venue =

What dw model is appropriate when there's no measure?

和自甴很熟 提交于 2020-01-06 18:38:47
问题 All the demos out there use a sales/order model as a measure in their examples. But my db is not transactional. It's a customer-centric model where there is one table for the customer which is joined to several attribute tables. Does this not even qualify for cube building because of the different model, or is there some way to still build cubes despite it not being transactional? I've heard of factless fact tables but don't really understand the concept yet. Is this where you would use one?

What dw model is appropriate when there's no measure?

假装没事ソ 提交于 2020-01-06 18:38:08
问题 All the demos out there use a sales/order model as a measure in their examples. But my db is not transactional. It's a customer-centric model where there is one table for the customer which is joined to several attribute tables. Does this not even qualify for cube building because of the different model, or is there some way to still build cubes despite it not being transactional? I've heard of factless fact tables but don't really understand the concept yet. Is this where you would use one?

Inactive relationships affecting measures

随声附和 提交于 2020-01-05 04:33:11
问题 I have the following tables & relationships in our pbix report: For some obvious reasons, I need to have a relationship (non-active) between Dates[date] and Table2[T2Date]. However, doing so causes data fluctuation to measure 'Total Amount' in Table1. Here are some screenshots: Before Relationship (Dates[date] - Table2[T2Date]): After Relationship (Dates[date] - Table2[T2Date]): I need to understand why this difference is coming up and how the relationship is causing it since the measure uses

How to remove rows after a particular observation is seen for the first time

我怕爱的太早我们不能终老 提交于 2020-01-04 07:54:38
问题 I have a dataset wherein I have account number and "days past due" with every observation. For every account number, as soon as the "days past due" column hits a code like "DLQ3", I want to remove rest of the rows for that account (even if DLQ3 is the first observation for that account). My dataset looks like: Obs_month Acc_No OS_Bal Days_past_due 201005 2000000031 3572.68 NORM 201006 2000000031 4036.78 NORM 200810 2000000049 39741.97 NORM 200811 2000000049 38437.54 DLQ3 200812 2000000049

How to remove rows after a particular observation is seen for the first time

a 夏天 提交于 2020-01-04 07:54:11
问题 I have a dataset wherein I have account number and "days past due" with every observation. For every account number, as soon as the "days past due" column hits a code like "DLQ3", I want to remove rest of the rows for that account (even if DLQ3 is the first observation for that account). My dataset looks like: Obs_month Acc_No OS_Bal Days_past_due 201005 2000000031 3572.68 NORM 201006 2000000031 4036.78 NORM 200810 2000000049 39741.97 NORM 200811 2000000049 38437.54 DLQ3 200812 2000000049

Mysql: enum confusion

為{幸葍}努か 提交于 2020-01-02 10:07:16
问题 I have an employee table, employee has interests, so the table can be designed like this: create table emp( id int(10) not null auto_increment, name varchar(30), interest varchar(50), primary key(id) ); or this: create table emp( id int(10) not null auto_increment, name varchar(30), interest enum('football','basketball','music','table tennis','volleyball'), primary key(id) ); The number of interests can be about 50. How should i design the table? Should i use enum or others ? Edit: Thanks for

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

百般思念 提交于 2020-01-02 05:24:06
问题 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