database-design

One schema for all or separation of Schema for each customer?

Lets say you build an application which needs to serve several customers (data is never shared between customers) and the customer data itself is sensitive. How would you design the database to prevent that suddenly (e.g. a bug) data from one customer is visible to another? E.g. We have a projects table which contains projects of a cus...

Should a many-to-many relationship define anything other than the relationship

Taking the typical products / categories many-to-many relationship you'd typically have a relationship like follows: table -- ProductsCategories column - ProductId column - CategoryId Is it ill advised to add other properties to that relationship, things that only exist on that specific relationship. Such as (please forgive my terribl...

Creating a new text column in a SQL Server Table: which type should I choose?

I have a text field that can be 30 characters in length, however it can achieve around 2.000 characters. For "future safety", it would be nice if this new column could support until 3.000 characters. I think the average size of this field is 250 characters. Which SQL Server 2000 data type is better to increase performance and disk spac...

Database development mistakes made by application developers

What are common database development mistakes made by application developers? ...

Insert variables and arrays in different database tables using PHP and MySQLi

Hi, I'm learning PHP and MySQL and I'm creating a movies website for learning purposes. I want to insert variables and arrays containing movie info into a database but in different tables. This is what I have right now: include('inc/connection.php'); $conn = dbConnect(); // create SQL $sql = 'INSERT INTO movies (movieid, title, year,...

What is the best-practice, don't-work-yourself-into-a-corner way to add comments to many models?

Hi Stack Overflowers: I'm building a Ruby on Rails application that has several different models (e.g. Movie, Song, Photo) that I am storing movie clips, mp3s and photos. I'd like for users to be able to comment on any of those Models and have control over which comments are published. Is the best practice to create a Comment model with...

Best Database structure for storing RSS feeds

I've been searching around trying to find an answer both here and google, although I've found some pointers I haven't quite found a solution. If you have a simple RSS reader with a database, you might have a couple of tables for storing feeds (ignoring dealing with subscribers here): Feeds (feed-id, feed-title, feed-url) Items (item-i...

A database design question

Hi! I have to store on a database four kinds of object on a database. These objects have the same atributes: Name (varchar2). Description (varchar2). File (Binary blob). Maybe I can use a table to store these objects adding a column to identify the kind of object but I need to store a lot of objects (> 1,000,000 or much more). My q...

Visually mapping mysql database schema

I need to visually understand the database schema of an open source erp software (Dolibarr), for that have found a java based tool dbschemaviewer which make use of eclipse and GEF to map out an existing database. I let it do the process overnight but no results I need some other software that can map existing database schema visually an...

Rails best practices - How do you handle unique users that may have identical records?

How do you handle real name conflicts? Is there an established best practice or UI design pattern for disambiguating records like this? If authors can have many articles but more than one author can possibly have the same name how would you enable users to select the author they actually want when creating articles? I can't dictate th...

Draft version of database table

I have a database with a report table. This table represents report data, and has constraints. Now the application is used by firemen, and they might have to run off and put out some fires. So in the middle of filling out data for this table, they might have to run off. What we do is when the session run out we save the data to a draft t...

designing for repetitive data

I am designing a product database and I have a design question. There are several different categories of products, say books, video games, home electronics, and pet supplies. There are some things in common, say the manufacturer, and price, while other things are unique to each category, say power consumption. The individual produc...

3rd Normal Form

For the given relation, determine the current normal form, and list the reason why it is in that normal form. Then, using ONLY the information given, transform the relation into third normal form. Note that by default all attributes are depended on the composite primary key. Order( CID, VesselID, VoyID, VoyDest, EID, ContID, CDESC...

Normalize out to different databases?

What are everyone's opinions on normalizing a database out across multiple databases. For instance, say you had a database that allowed different clients to sell products. You had abstracted the concept of an order, order item, etc., but each client wants a different field added here or there. You could add the fields to the specifi...

SQL Server - Performance/Size Drawbacks of Null Columns

I'm working on a table design that could involve many NULL values in about 10 fields maybe 75% of the time the fields would be unused. I just generated some fake data (a million records) and could not sense any impact on SQL Server 2005. Size difference was in the KB. Performance - no measurable difference after adding an index to the 3...

Preparing to move to a single database

We have an application that has 1000+ databases and 600+ sprocs. Each database represents a different client. Problem: We need to move this to a single database while creating as little effect on the ui as possible, meaning dont change all the sproc signatures at 1 time. The connection string currently sets the database attribute, a ...

In a database, would you use a date field or year and month fields if you only need year and month?

I am setting up a table where I need the year and month. In MySQL I believe I have 2 options: (1) 2 fields: 1 for year, 1 for month or (2) a date field (the day would always be 1). The 2 fields has the advantage of being some what faster (I think) because MySQL doesn't have to convert the value from a date to an integer although this is...

How may I store contact methods (or similar typed data with different fields) in a normalized way?

I've crossed this problem in, oh, every application I've ever written. I'd like a final consensus answer! Is this the most normalized/efficient/proper way to store contact methods or any other data along this pattern in a database? Contact { PK ContactId, ... } ContactContactMethod {PK FK ContactId, PK FK ContactMethodId, Key, Commen...

Elegant database design help... (MySQL/PHP)

Hi, I'm building a movies website... I need to display info about each movie, including genres, actors, and a lot of info (IMDB.com like)... I created a 'movies' table including an ID and some basic information. For the genres I created a 'genres' table including 2 columns: ID and genre. Then I use a 'genres2movies' table with two colum...

Are there any books on designing and building database management systems?

Hi, are there any books on designing and building database software (not organizing table layouts), like optimum file formats etc. ...