data-modeling

How can I avoid NULLs in my database, while also representing missing data?

佐手、 提交于 2019-11-28 15:44:38
In SQL and Relational Theory (C.J. Date, 2009) chapter 4 advocates avoiding duplicate rows, and also to avoid NULL attributes in the data we store. While I have no troubles avoiding duplicate rows, I am struggling to see how I can model data without making use of NULL . Take the following, for example - which is a bit from work. We have an artist table, which has, amongst other columns, a gender column. This is a foreign key to the gender table. However, for some artists, we don't know their gender - for example we've been given a list of new music which has no descriptions of the artist. How,

Why many refer to Cassandra as a Column oriented database?

感情迁移 提交于 2019-11-28 14:36:07
问题 Reading several papers and documents on internet, I found many contradictory information about the Cassandra data model. There are many which identify it as a column oriented database, other as a row-oriented and then who define it as a hybrid way of both. According to what I know about how Cassandra stores file, it uses the *-Index.db file to access at the right position of the *-Data.db file where it is stored the bloom filter, column index and then the columns of the required row. In my

Storing multiple choice values in database

余生长醉 提交于 2019-11-28 11:43:49
Say I offer user to check off languages she speaks and store it in a db. Important side note, I will not search db for any of those values, as I will have some separate search engine for search. Now, the obvious way of storing these values is to create a table like UserLanguages ( UserID nvarchar(50), LookupLanguageID int ) but the site will be high load and we are trying to eliminate any overhead where possible, so in order to avoid joins with main member table when showing results on UI, I was thinking of storing languages for a user in the main table, having them comma separated, like "12

Data modeling question

一笑奈何 提交于 2019-11-28 10:08:40
问题 My clients use one of the following when they sign up for my application: Foo API (requires a " auth_key ", " password ", " email ") Acme API (requires a " secure_code ", " username ", " password ") Bar API (requires a " xyz_code ", " pass_key ") (fake names, and about 15 more omitted for simplicity) I would prefer not to have 10-15 tables in my database just for the different API integration options I offer (particularly when they're all for the same thing and they just choose 1 from the

Entity Framework CTP5 Code-First Mapping - Foreign Key in same table

∥☆過路亽.° 提交于 2019-11-28 04:43:22
问题 How would I map something like this using the modelBuilder? Where theres a nullable foreign key referencing the same tables primary key Table: Task taskID int pk taskName varchar parentTaskID int (nullable) FK Task class: public class Task { public int taskID {get;set;} public string taskName {get;set;} public int parentTaskID {get;set;} public Task parentTask {get;set;} } ... modelBuilder.Entity<Task>() .HasOptional(o => o.ParentTask).... 回答1: The following code gives you the desired schema.

Why should I avoid loops when designing relationships for a database?

[亡魂溺海] 提交于 2019-11-28 04:38:15
Someone told me that it was bad design to have loops in the datamodel. I have heard this before a couple of times but didn't pay much attention. For example you have entities User, Project, Activity. A project is owned by a User, so we have a one-to-many relationship from user to Project. An activity can be assigned to a single User, another one-to-many relationship from User to Activity. Of course a project is defined by a set of activities, another one-to-many relationship from Project to Activity. Thus a loop is formed. I asked this guy why is it bad design but he told me he didn't know

Cloud Firestore deep get with subcollection

馋奶兔 提交于 2019-11-28 04:04:46
Let's say we have a root collection named 'todos'. Every document in this collection has: title : String subcollection named todo_items Every document in the subcollection todo_items has title : String completed : Boolean I know that querying in Cloud Firestore is shallow by default, which is great, but is there a way to query the todos and get results that include the subcollection todo_items automatically? In other words, how do I make the following query include the todo_items subcollection? db.collection('todos').onSnapshot((snapshot) => { snapshot.docChanges.forEach((change) => { // ... }

Max Tables & Design Pattern

拜拜、爱过 提交于 2019-11-28 02:16:37
问题 I am working on an app right now which has the potential to grow quite large. The whole application runs through a single domain, with customers being given sub-domains, which means that it all, of course, runs through a common code-base. What I am struggling with is the database design. I am not sure if it would be better to have a column in each table specifying the customer id, or to create a new set of tables (in the same database), or to create a complete new database per customer. The

Sql recursion without recursion

99封情书 提交于 2019-11-28 00:31:03
问题 I have four tables create table entities{ integer id; string name; } create table users{ integer id;//fk to entities string email; } create table groups{ integer id;//fk to entities } create table group_members{ integer group_id; //fk to group integer entity_id;//fk to entity } I want to make a query that returns all groups where a user belongs, directly or indirectly. The obvious solution is to make a recursion at the application level. I’m wondering what changes can I make to my data model

Database modeling for a weak entity

 ̄綄美尐妖づ 提交于 2019-11-27 21:41:15
I have 2 tables in my database orders and orderHistory . ----------------- ----------------------- | orders | | orderHistory | ----------------- ----------------------- | orderID (PK) | | historyLineID (PK) | | orderDate | | status | | price | | quantity | ----------------- ----------------------- Now an order can have multiple history lines . However, a history line can't exist on its own. I heard this is called a weak entity and therefore the PK from orders must be part of the PK of table orderHistory . Questions Is this really a correct weak entity relationship? Is there other ways to