database-design

unnecessary normalization

My friend and I are building a website and having a major disagreement. The core of the site is a database of comments about 'people.' Basically people can enter comment and they can enter the person the comment is about. Then viewers can search the database for words that are in the comment or parts of the person name. It is complete...

Database design & table relationships: where would the data go? (Image included).

I need to carryout a data capture exercise, which is looking like a large task, that unfortunately may end up being done in excel. I believe a database is more suitable, but the structure of it is probably very complicated. I've created 4 categories per Unit (30 units). Each category has 8 graphs/dimensions. Each graph/dimension has a s...

Appropriate way to structure a database table? (empty columns vs. multiple tables)

Let's say we have a object called a Widget, for which we can construct a database table. Now, let's say we have two sets of additional detail to describe widgets. Each set of data is available at a separate time. So, let's say our widgets have three phases to their life-cycle... In phase 1, we simply have a widget with a name and a des...

Composite primary key comprising two foreign keys referencing same table: SQL Server vs. MySQL

I've read over a number of posts regarding DB table design for a common one-to-many / users-to-friends scenario. One post included the following: USERS * user_id (primary key) * username FRIENDS * user_id (primary key, foreign key to USERS(user_id)) * friend_id (primary key, foreign key to USERS(user_id)) > This will s...

How do I find the count of columns before the first occurrence of LIKE?

Sorted on column Y X Y Z ------------------------ | | A1 | | ------------------------ | | B2 | | ------------------------ | | C3 | | ------------------------ -----Page 1 | | D3 | | ------------------------ | | E4 | | ------------------------ | | ...

How do I add dimensions to textual data in a database?

I have some content in a database, but now I need to add two more dimensions to the content: Language and Reading Level. What is the best way to make content multidimensional? For example, here's the table I have: |-------------| | Food | |-------------| | id | | name | | description | | ... | |----------...

ERD for two locations

I am desining a database and got stuck with this issue: My case is to design an ERD to keep track of the cars and their movements from location to location. The users utilize a form which contains three fields: The first one is used to enter the car#. The second field is used to enter the location the car came from (From_Location) and...

Database table names: Plural or Singular

What is the most common naming convention for SQL Database tables? Was it historically one way and now it's better to do another way? What are the most common practices now? ...

DB Schema for Storing Edit-History

I am designing a system which will include a history of edits made to user posts. I expect roughly 1/3 of the posts made by my users to include edits of some kind. Most of those will have only a handful of versions. Reaching the double digits will be very rare. What is the best schema to represent this data in the database? What tables ...

Django DB design to glob words quickly

I need to quickly look up words for a web application that I am writing in Django. I was thinking of putting each character of the word in an integerfield of its own, indexed by position. class Word(models.Model): word = models.CharField(max_length=5) length = models.IntegerField() c0 = models.IntegerField(blank=True, null...

Bad real-world database schemas

Hello all-knowing co-stackers. Our masters thesis project is creating a database schema analyzer. As a foundation to this, we are working on quantifying bad database design. Our supervisor has tasked us with analyzing a real world schema, of our choosing, such that we can identify some/several design issues. These issues are to be used...

SQL for a movie database search system

I am building up a database of movies. Each movie will have fields genre, actors, director etc. Now my question is how do I design a database and write SQL as each movies can have multiple actors or directors etc. Right now my database design for table movie is: movie_id movie_title actors_id directors_id genre_id But this way it se...

MySQL performance with partition option.

Hello, I've designed mysql tables for bookings. One of them has hotels_id, rt_id, -> (room_type_id), date ..... Every rt_id has 365 rows (date). And every hotels_id has some rt_id (room types) for example 500 hotels and 8 room types per hotel -> 500 x 8 x 365 = 1.460.000 rows. I've used column index option for " hotels_id, rt_id, da...

DB design strategy in Visual Studio

Hi All, I'm currently investigating ASP.NET MVC 2 and LINQ to SQL. It all looks pretty cool. But I have a few application and development lifecycle issues. Currently, I design the DB in SqlServer Management Studio. Then I update my DBML files by deleting and re-importing modified tables. Issues: I can't find how to simply update the...

What is the preferred way of saving dynamic lists in database?

In our application user can create different lists (like sharepoint) for example a user can create a list of cars (name, model, brand) and a list of students (name, dob, address, nationality), e.t.c. Our application should be able to query on different columns of the list so we can't just serialize each row and save it in one row. Shou...

Lookup tables question

Possible Duplicate: database design question For performance and future data editing, is it better to store all lookup values in 1 table or each to its own table? I have items like Industry, Sub industry, Sector, Sector type, etc Each of these have between 5 to 50 values. Each can be related like Sector belongs to Sector type....

Designing the schema for an inventory system...should I calculate quantity or keep track of it?

I'm doing an inventory for a game, rather like a FF-style game. I have two design in mind, and wonder which is better Keep track of quantity as a field; the schema would be: item ( <item_id>, <character_id>, quantity ). If a character equip an item, or remove an item from his inventory, I would need to make sure the quantity field is c...

Table with 80 million records and adding an index takes more than 18 hours (or forever)! Now what?

A short recap of what happened. I am working with 71 million records (not much compared to billions of records processed by others). On a different thread, someone suggested that the current setup of my cluster is not suitable for my need. My table structure is: CREATE TABLE `IPAddresses` ( `id` int(11) unsigned NOT NULL auto_incremen...

Create a view from table with dynamic where clause

I have a table with a column called YEAR. I would like to create a view from this table, with YEAR always equal to the one with max value. Whenever new records with YEAR values greater than the current max one are inserted, the view would automatically be reflected accordingly. Is this possible and if so how can I accomplish that. ...

Which MySQL schema would is optimal for this type of system

Assuming a system similar to Netflix where members create a wish list of movies and, based on their type of plan, one, two, or more of those movies in their list turn into orders, which one of the following schemas makes more sense? A controls table storing the following columns: controls(memberid, currentMoviesAtHome, moviesAtHomeLim...