data-modeling

Are soft deletes a good idea? [duplicate]

流过昼夜 提交于 2019-11-26 12:38:28
This question already has an answer here: Physical vs. logical / soft delete of database record? 22 answers Are soft deletes a good idea or a bad idea? Instead of actually deleting a record in your database, you would just flag it as IsDeleted = true , and upon recovery of the record you could just flag it as False . Is this a good idea? Is it a better idea to physically delete the record, then move it to an archive database, and if the user wants the record back, then software will look for the record in the archive and recreate it? I say it's a bad idea, generally (with some exceptions,

What mysql database tables and relationships would support a Q&A survey with conditional questions? [closed]

谁说胖子不能爱 提交于 2019-11-26 12:36:27
I'm working on a fairly simple survey system right now. The database schema is going to be simple: a Survey table, in a one-to-many relation with Question table, which is in a one-to-many relation with the Answer table and with the PossibleAnswers table. Recently the customer realised she wants the ability to show certain questions only to people who gave one particular answer to some previous question (eg. Do you buy cigarettes? would be followed by What's your favourite cigarette brand? , there's no point of asking the second question to a non-smoker). Now I started to wonder what would be

Alternatives to Entity-Attribute-Value (EAV)?

穿精又带淫゛_ 提交于 2019-11-26 12:21:01
问题 Our database is designed based on EAV (Entity-Attribute-Value) model. Those who have worked with EAV models know all the crap that comes with for the purpose of flexibility. I asked my client about the reasons why using EAV model (flexibility), and their response was: Their entities change over time. So, today they may have a table with a few attributes, but in a month time, a few new attributes may be added, or an existing attribute may be renamed. They need to produce reports to get back to

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone

夙愿已清 提交于 2019-11-26 11:48:47
问题 What\'s the longest possible worldwide phone number I should consider in SQL varchar(length) for phone. considerations: + for country code () for area code x + 6 numbers for Extension extension (so make it 8 {space}) spaces between groups (i.e. in American phones +x xxx xxx xxxx = 3 spaces) here is where I need your help, I want it to be worldwide Consider that in my particular case now, I don\'t need cards etc. number begins with country code and ends with the extension, no Fax/Phone etc.

What are design patterns to support custom fields in an application?

给你一囗甜甜゛ 提交于 2019-11-26 11:46:28
问题 We develop a commercial application. Our customers are asking for custom fields support. For instance, they want to add a field to the Customer form. What are the known design patterns to store the field values and the meta-data about the fields? I see these options for now: Option 1 : Add Field1, Field2, Field3, Field4 columns of type varchar to my Customer table. Option 2 : Add a single column of type XML in the customer table and store the custom fields\' values in xml. Option 3 : Add a

Best way to model Customer <--> Address

孤街浪徒 提交于 2019-11-26 10:55:48
问题 Every Customer has a physical address and an optional mailing address. What is your preferred way to model this? Option 1. Customer has foreign key to Address Customer (id, phys_address_id, mail_address_id) Address (id, street, city, etc.) Option 2. Customer has one-to-many relationship to Address , which contains a field to describe the address type Customer (id) Address (id, customer_id, address_type, street, city, etc.) Option 3. Address information is de-normalized and stored in Customer

How to Model a “likes” voting system with MongoDB

╄→гoц情女王★ 提交于 2019-11-26 10:30:20
Currently I am working on a mobile app. Basically people can post their photos and the followers can like the photos like Instagram. I use mongodb as the database. Like instagram, there might be a lot of likes for a single photos. So using a document for a single "like" with index seems not reasonable because it will waste a lot of memory. However, I'd like a user add a like quickly. So my question is how to model the "like"? Basically the data model is much similar to instagram but using Mongodb. Neil Lunn No matter how you structure your overall document there are basically two things you

How to implement has_many :through relationships with Mongoid and mongodb?

微笑、不失礼 提交于 2019-11-26 10:07:41
问题 Using this modified example from the Rails guides, how does one model a relational \"has_many :through\" association using mongoid? The challenge is that mongoid does not support has_many :through as ActiveRecord does. # doctor checking out patient class Physician < ActiveRecord::Base has_many :appointments has_many :patients, :through => :appointments has_many :meeting_notes, :through => :appointments end # notes taken during the appointment class MeetingNote < ActiveRecord::Base has_many

What are the principles behind, and benefits of, the “party model”?

不羁岁月 提交于 2019-11-26 09:24:59
问题 The \"party model\" is a \"pattern\" for relational database design. At least part of it involves finding commonality between many entities, such as Customer, Employee, Partner, etc., and factoring that into some more \"abstract\" database tables. I\'d like to find out your thoughts on the following: What are the core principles and motivating forces behind the party model? What does it prescribe you do to your data model? (My bit above is pretty high level and quite possibly incorrect in

Finding the best trade-off point on a curve

六月ゝ 毕业季﹏ 提交于 2019-11-26 08:54:57
问题 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