database-design

Fixed-size array database field

I need to store several date values in a database field. These values will be tied to a "User" such that each user will have their own unique set of these several date values. I could use a one-to-many relationship here but each user will have exactly 4 date values tied to them so I feel that a one-to-many table would be overkill (in ma...

DB sketcher for MacOS?

I've been trying to find a free database creator for mac os, and i'm not being able to find any. Anyone know of a free one i could download? EDIT: I need that the application generate the sql (mysql in this case) also :) ty ...

Optimal data architecture for tagging, clouds, and searching (like StackOverflow)?

I'd love to know how Stack Overflow's tagging and search is architected, because it seems to work pretty well. What is a good database/search model if I want to do all of the following: Storing Tags on various entities, (how normalized? i.e. Entity, Tag, and Entity_Tag tables?) Searching for items with particular tags Building a ta...

What is the best practice for naming database tables to provide natural organization?

We put common prefixes on related tables to assure they display next to each other in our DB management software (Toad, Enterprise Manager, etc). So for example, all user tables start with the word User: User UserEvent UserPurchase Ideally, in honor of the three great virtues of a programmer these tables should be named User, Eve...

Database : best way to model a spreadsheet

I am trying to figure out the best way to model a spreadsheet (from the database point of view), taking into account : The spreadsheet can contain a variable number of rows. The spreadsheet can contain a variable number of columns. Each column can contain one single value, but its type is unknown (integer, date, string). It has to be e...

Mirroring Table Modifications

I have a set of tables that are used to track bills. These tables are loaded from an SSIS process that runs weekly. I am in the process of creating a second set of tables to track adjustments to the bills that are made via the web. Some of our clients hand key their bills and all of those entries need to be backed up on a more regular s...

Database tables / fields you always use in your killer apps

I'm hoping to tap into some collective experience here, so What (if any) utility tables, or common fields do you always include in your database design? An example is that I always include an App_Errors table to store any uncaught exception information in, and an App_Audit table which stores all the edit information. I've mooted (in my...

Should you make a self-referencing table column a foreign key?

For example to create a hierarchy of categories you use a column 'parent_id', which points to another category in the same table. Should this be a foreign key? What would the dis/advantages be? ...

What is Normalisation (or Normalization)? Why is it important?

Why do database guys go on about normalisation? What is it? How does it help? Is it even that important? Does it apply to anything outside of databases? ...

Can source code examples be kept in a SQL database while retaining all formatting? If so...

Can source code examples be kept in a SQL database while retaining all formatting (tabs, newlines, etc.)? If so what data type would be used? ...

designing model structure for django

Hi, I'm trying to design a model for a application allowing 2 people to bet with each other (I know, sounds stupid...). What I'm wondering about is how to connect the bet with users. The structure is like this |-------------| |----------| | Bet | | User | | BetUser1 | |----------| | BetUser2 | | Winn...

Sql Data Type for Primary Key - SQL Server?

Which sql data type should we use for number bases primary key: int bigint numeric float ...

Should I use a single or multiple database setup for a multi-client application?

Hi everyone, I am working on a PHP application that intends to ease company workflow and project management, let's say something like Basecamp and GoPlan. I am not sure on what the best approach is, database-wise. Should I use a single database and add client-specific columns to each of the tables, or should I create a database for eac...

Django models - how to filter number of ForeignKey objects

I have a models A and B, that are like this: class A(models.Model): title = models.CharField(max_length=20) (...) class B(models.Model): date = models.DateTimeField(auto_now_add=True) (...) a = models.ForeignKey(A) Now I have some A and B objects, and I'd like to get a query that selects all A objects that have less then 2 ...

Best-practices for localizing a SQL Server (2005/2008) database

Question I'm sure many of you have been faced by the challenge of localizing a database backend to an application. If you've not then I'd be pretty confident in saying that the odds of you having to do so in the future is quite large. I'm talking anout storing multiple translations of texts (and the same can be said for currency etc.) f...

Data Model for Boolean Expressions

Do you know a way to organize boolean expressions in a database while allowing infinite nesting of the expressions? Example: a = 1 AND (b = 1 OR b = 2) The expression as a whole shouldn't be stored as varchar to preserve data integrity. ...

Good (== fast) storage strategy for facts with dynamically evolving dimensions?

I need to store large amounts of metering data in a database. A record consists of an id that identifies the data's source, a timestamp and a value. The records are later retrieved via the id and their timestamp. According to my previous experience (I am developing the successor of an application that's been in productive use over the l...

How to Structure Table to Model Mutually Exclusive 1:n Relationships?

In the following table structure: Fruits ( fruit_id, fruitName ) Vegetables ( vegetable_id, vegetableName ) favoriteFoods ( food_id, foodName, type_id (References either a fruit or a vegetable) ) I realize that I could forgo using a foreign key constraint on the favoriteFoods table and then simply a...

How to store URLs in a table?

I think the field type should be string of variable length (VARCHAR), but what length should I use? To clarify: I want to pick a size that would be able to store average URL, and don't really care about maximum possible. ...

Guesstimating database size.

I'm trying to foresee how big my database will be. Let's say I have only one table: CREATE TABLE user ( id INT UNSIGNED NOT NULL AUTO_INCREMENT, email VARCHAR(50), pass CHAR(40), url VARCHAR(1000), PRIMARY KEY(id)); Adding all up: 4 + 51 + 40 + 1001 = 1096 bytes in one record. If I have 1 million records: 1,000,000 x 1096 bytes = 1,...