data-modeling

What's the best way to model recurring events in a calendar application?

て烟熏妆下的殇ゞ 提交于 2019-11-26 21:12:38
I'm building a group calendar application that needs to support recurring events, but all the solutions I've come up with to handle these events seem like a hack. I can limit how far ahead one can look, and then generate all the events at once. Or I can store the events as repeating and dynamically display them when one looks ahead on the calendar, but I'll have to convert them to a normal event if someone wants to change the details on a particular instance of the event. I'm sure there's a better way to do this, but I haven't found it yet. What's the best way to model recurring events, where

Relational database design question - Surrogate-key or Natural-key?

人盡茶涼 提交于 2019-11-26 21:05:20
Which one is the best practice and Why ? a) Type Table, Surrogate/Artificial Key Foreign key is from user.type to type.id : b) Type Table, Natural Key Foreign key is from user.type to type.typeName : I believe that in practice, using a natural key is rarely the best option. I would probably go for the surrogate key approach as in your first example. The following are the main disadvantages of the natural key approach: You might have an incorrect type name, or you may simply want to rename the type. To edit it, you would have to update all the tables that would be using it as a foreign key. An

What should I name a table that maps two tables together? [closed]

主宰稳场 提交于 2019-11-26 18:48:55
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . Let's say I have two tables: Table: Color Columns: Id, ColorName, ColorCode Table: Shape Columns: Id, ShapeName, VertexList What should I call the table that maps color to shape? Table: ??? Columns: ColorId, ShapeId 回答1: There are only two hard things in Computer Science:

Finding the best trade-off point on a curve

∥☆過路亽.° 提交于 2019-11-26 18:24:53
Say I had some data, for which I want to fit a parametrized model over it. My goal is to find the best value for this model parameter. I'm doing model selection using a AIC / BIC / MDL type of criterion which rewards models with low error but also penalizes models with high complexity (we're seeking the simplest yet most convincing explanation for this data so to speak, a la Occam's razor ). Following the above, this is an example of the sort of things I get for three different criteria (two are to be minimized, and one to be maximized): Visually you can easily see the elbow shape and you

DB design to use sub-type or not?

冷暖自知 提交于 2019-11-26 17:54:53
The database I'm designing has 3 major tables: BOOKS , ARTICLES , NOTES . Each book or article can have multiple notes, my original design was just like that, which means both notes on books and notes on articles go the 'notes' table. Here are the columns for the NOTES table: note_id note_type note_type_id note_content NOTE_TYPE can be either 'book' or 'article'; NOTE_TYPE_ID is the FK for a book_id if the note_type is 'book' OR an article id if the note_type is 'article'. Now I start to wonder if that's the correct(or best normalized) design. An alternative approach is to use 5 tables books /

Should OLAP databases be denormalized for read performance?

谁说我不能喝 提交于 2019-11-26 17:53:17
问题 I always thought that databases should be denormalized for read performance, as it is done for OLAP database design, and not exaggerated much further 3NF for OLTP design. PerformanceDBA in various posts, for ex., in Performance of different aproaches to time-based data defends the paradigm that database should be always well-designed by normalization to 5NF and 6NF (Normal Form). Have I understood it correctly (and what had I understood correctly)? What's wrong with the traditional

What are the design criteria for primary keys?

夙愿已清 提交于 2019-11-26 17:46:13
Choosing good primary keys, candidate keys and the foreign keys that use them is a vitally important database design task -- as much art as science. The design task has very specific design criteria. What are the criteria? The criteria for consideration of a primary key are: Uniqueness Irreducibility (no subset of the key uniquely identifies a row in the table) Simplicity (so that relational representation & manipulation can be simpler) Stability (should not be altered frequently) Familiarity (meaningful to the user) What is a Primary Key? The primary key is something that uniquely identifies

how to design a schema where the columns of a table are not fixed

烈酒焚心 提交于 2019-11-26 17:21:27
问题 I am trying to design a schema where the columns of a table are not fixed. Ex: I have an Employee table where the columns of the table are not fixed and vary (attributes of Employee are not fixed and vary). Frequent addition of a new attribute / column is requirement. Nullable columns in the Employee table itself i.e. no normalization Instead of adding nullable columns, separate those columns out in their individual tables ex: if Address is a column to be added then create table Address

Firestore: Query by item in array of document

瘦欲@ 提交于 2019-11-26 15:21:46
I have a document "user" which has a key called "photos". Here is an array of strings being saved, namely the IDs of the "photo" documents. I want to query "user" by this "photos" field: I want all users who have this ID in the "photos" property. Is this possible through firestore? Added 'array-contains' query operator for use with .where() to find documents where an array field contains a specific element. https://firebase.google.com/support/release-notes/js 5.3.0 Update : also available in @google-cloud/firestore : https://github.com/googleapis/nodejs-firestore/releases/tag/v0.16.0 Update 2

single fixed table with multiple columns vs flexible abstract tables

情到浓时终转凉″ 提交于 2019-11-26 14:00:46
I was wondering if you have a website with a dozen different types of listings (Shops, Restaurants, Clubs, Hotels, Events) that require different fields, is there a benefit of creating a table with columns defined like so Example Shop: shop_id | name | X | Y | city | district | area | metro | station | address | phone | email | website | opening_hours Or a more abstract approach similar to this: object_id | name --------------- 1 | Messy Joe's 2 | Bate's Motel type_id | name --------------- 1 | hotel 2 | restaurant object_id | type_id --------------- 1 | 2 2 | 1 field_id | name | field_type --