database-design

Rails - Separate Database per Subdomain

Hello all, I am about to begin writing a Rails application that will allow clients to have a separate subdomain for their access to our application. Thinking from a data security standpoint, it would be nice if each client's access was truly limited to their database, that way, if there is a bug in production code, they would only be ab...

What is the best way to design database for Ruby on Rails?

I know there are many database design tool, database modeling tool. Example, ER-win , db desginer and etc. But, they are not supported for Ruby on Rails. What is the best way or tool to design database for Ruby on Rails? Appended: I know the rails development phases are growing step by step. But, When starting of project, I think da...

More tables or more databases?

Hello to all, I am setting up a system to host WordPress blogs for users of a site I run. Right now, things are functioning pretty well within one database and different blogs running with their own prepended tables (user1_posts, user_posts, etc). Despite this working so far, it feels a bit messy. If this database were to have 4000 t...

a layman's term for identifying relationship

There are couples of questions around asking for difference / explanation on identifying and non-identifying relationship in relationship database. My question is, can you think of a simpler term for these jargons? I understand that technical terms have to be specific and unambiguous though. But having an 'alternative name' might help ...

Overkill to add last_modified column to all tables?

When designing database tables for a fresh new project, is it good practice to add a last_modified column, which auto-updates, for every table? Is the performance hit to have auto-updating last_modified columns too much to make it worthwhile? This column could have a number of uses, one being to aid with caching. But is it overkill to ...

Must Django ManyToManyField association tables have a surrogate key?

I'm mapping an existing database structure into Django models. I have a many-to-many structure where the association table is natural-keyed: CREATE TABLE foo (id INTEGER PRIMARY KEY); CREATE TABLE bar (id INTEGER PRIMARY KEY); CREATE TABLE foo2bar (foo_id INTEGER REFERENCES foo(id), bar_id INTEGER REFERENCES bar(id...

Any excuse for "shortcut" columns in a db schema?

Yesterday i noticed a foreign key column in a details table that linked directly to a customer table. This details table is just one join removed by a header table from the customer which already the proper foreign key to the customer and the detail, Bear with me. [Cust] ---< [Header] ---< [Detail] | V |____...

what's the best way to represent a many-to-many relationship in a database?

If I have a number of users and a number of pages, and each user can administrate any number of the pages, and each page can be administrated by any number of the administrators, how could I store all of these permissions in a database? For example, I could have a field in the users table, which is just a comma-delimited list of page ID...

Are there Database Systems more suited to Social Networks?

This question is inspired by the article "Why are Facebook, Digg, and Twitter so hard to scale?" on highscalability.com So what database systems(however obscure) are out there that would be able to handle this type of data better? Thanks for you help! ...

Design for a data store that can be updated and queried against at the same time

We are designing a real-time inventory system for an e-commerce site that aggregates its inventory from multiple suppliers. Our visitors can search and purchase items from our site We get inventory updates from multiple suppliers on different schedules throughout the hour. The updates comes in the form of an inventory snapshot of the...

Simple Database Table Design/Layout

I'm just wondering, as a hypothetical example, what would be the best way to layout a table for the following scenario: Let's say I'm writing an app for tracking student attendance. At the beginning of every year, I want to add all the students in (I'll do this manually - now, should a student ID be assigned to each one here? Let's call...

Temporal data with Rails / Active Record

I'm looking for ideas/information about managing temporal data with Active Record (Rails). One example would be the emplyoment history (working 100% in january, but only 80% from february up to now). This proably would be easy to tackle with a traditional 'has-many :eployment_parts'. But there's another case where the user can plan somet...

Core Data Deletion rules and many-to-many relationships

Say you have departments and employees and each department has several employees, but each employee can also be part of several departments. So there is a many-to-many relationship between employees and departments. When deleting a department I would like to delete all employees that are only part of that department and nullify the rela...

Best design pattern for database table joins

I'm looking at programming/design patterns for the model layer of my application, and am wondering which one fits best with the situation where you are doing a retrieval that involves joins across multiple tables. For example, suppose you have the following tables/relations: Customer --> 1..n Accounts --> 0..n Features where a Feature...

Should I break 1 table out to many if it will be hit often?

Right now I have a table for Photos. I expect this table to be hit a lot. Will I improve performance if I break it out into 3 tables if, for exmaple, I have 3 different types of photos? Or will this not improve performance? ...

Help with database schema for 50+GB DB

Hi all, I have a task to store large amount of gps data and some extra info in database and to access it for reporting and some other non frequent tasks. When I recieve a message from gps device it can have variable number of fields. For example Message 1: DeviceId Lat Lon Speed Course DIO1 ADC1 Message 2: DeviceId Lat Course DIO2 ...

How to create SQL query for "Likes in common"

Currently I'm building a system (php and mysql), that on the user profile allows you to add "favorite music artists" to a list. 've been trying to figure out a way to compare the user likes to other users and return a "recommended friends". For example: User A Likes - 1 - 2 - 3 - 4 User B Likes - 1 <- A likes - 5 - 6 - 7 User C Likes...

Data in Sql Server should use Unicode?

I want to store English, French, German, Italian, and Spanish in a Sql Server 2005 database to be used with a .NET application. Can I get away with not using Unicode? Will there be any issues with these languages? ...

Need a simple, good (fairly priced) ER Tool

I've been using ERWin for about 10 years now. My version is ancient and I do not think it's worth paying the rediculous upgrade price! Problem is it's starting to show it's age - I've been using it primarliy for MS SQL. I wish I could justify Embarcadero's ER/Studio, but I just need something that will allow me to design a DB and sync ...

MYSQL, using unique table names VS using ids

Hello, I currently have 26 tables in a MYSQL database. My boss wants me to recreate those 26 tables whenever we have a new client, and append a client abbreviation of some sort to those new tables. So for example there's company1~system~users and company2~system~users and so on and so forth. I'd rather just add a table to the database ...