database-design

Composite Index vs. INCLUDE Covering Index in SQL Server

Hi Folks I understand that Composite Indexes are always used Left to Right (e.g. if an Index was on City, State, WHERE City = "Blah" or WHERE City = "Blah" AND State = "AA" would work fine but WHERE State = "AA" would not). Does this same principle apply to INCLUDE indexes? Thanks in advance! Clay ...

How do you store variables fields ?

Hi, I've a database where I've comments, votes, galleries, images, etc... For examples, galleries and images can be commented using the same form, then I'll store it in a single table, comment. I'm wondering how would store this type information in the comment table? Using a ENUM type, a foreign key against a type table, hardcoded on i...

Create Sql Database Tables from Business Objects

What is the best way to create Sql Server tables from business objects. For example I'm writing an application that has a user object to store user information. What's the best practice for creating tables from these objects? Create the objects first and then define the database or is there a tool to transform business objects into table...

How are efficient consecutive word searches implemented?

Search engines and databases allow you to use consecutive string search (such as "this is a test"), which matches this is a test that will match, but won't match test this is a. I know that some databases have built-in features that allow you to use the same functionality without writing a single line of code (e.g. MySQL's full text sea...

Database Design - Column In One Table References Two Tables

Here is an example of what I have (take Stack Overflow). I have 2 tables, Questions and Answers. I also have a Comments table. The Comments table will reference both Questions and Answers. How should I set up the database? Have 2 columns in Comments, a QuestionId and AnswerId. Have one table for both Questions and Answers? Have ...

Why grouping entities as "1,3,41" in entity field (!!!) is worse than GROUP table and foreign keys?

Yeah, so question looks like I'm kidding, but it turns out that there are "architects" that are convinced about first choice. Introduction: Some team X got a project from team Y, that have failed project. Team X should finish the project and add more features. But Customer left some guys from team Y to help develop the project. Customer...

Circular dependencies in foreign keys: use it or avoid it?

My application loads lots of data from a database into a complex data structure. The in-memory data structure ressembles the structure of the database, which means that if the database contains the following tables: table A, key is A1 table B, key is B1, one of the columns is a foreign key to [the key of] table A table C, key is C1, o...

SQL Server 2008 data types: which ones should i use?

I am trying to figure out which data types I should use for my tables. Does someone have a very good, simple, tutorial on SQL Server 2008 datatypes (has to be practical!) ? ...

sql server 2008 - adding a constraint

i am trying to add a constraint to a datatype of char(1) i would like the user to only be able to enter Y or N or n or Y i clicked on check constraint in the CHECK CONSTRAINT EXPRESSION window what am i supposed to enter? ...

Whats faster in Oracle? Small table with tree structure vs. Huge flat table.

Hi All. I'm designing an application that will use Oracle, and we have this department hierarchy that we need to map in our database. Some thing that looks like this (I'm pretty sure you all know what I'm talking about but I'll include a piece of the ERD just in case): So it will have data stored that looks like this: [1 | 0] [2 | ...

moving tables between databases

For a bit fall cleaning, I am moving 25 tables between MySQL databases (different pieces of hardware). This is not the WHOLE database, just 25 tables out of a few hundred... These tables don't really belong in there, I won't go into why for NDA reasons. Now, this is going to break a lot of code and sql queries. What is the best way t...

Should I store the parent and child in a row or only the child

Let's say I'm building a car rentals application, and at a point I have to show all available cars. In the DB, I have the following tables: Brand Model Cars In Model, there is a FK to Brand, let's say Brand_id So my question is: Cars table should have Brand and Model columns? Or only a Model column given that I could get the Brand...

NoSQL database with range queries

I'm looking for a NoSQL database that allows queries that return records that fall in the specified range. I'm not very good with the NoSQL nomenclature (as I'm still only researching whatever they will be viable) so I'll explain it how I would do it in SQL. What I'll need to do, is search for records (let's say forum posts), that are ...

Recommended database design for relationship between business hour and it's staff and their hours

Been going back and forth on how to architect this. I'm using rails,and started with Single-Table-Inheritance, then changed my mind, now I'm not sure. BusinessHours business_id, day_of_week, start_time, stop_time StaffHours staff_id, day_of_week, start_time, stop_time Obviously a staff member belongs to a business, however the tables ...

Essay Help. Database Design

When constructing a database, the designer must know what type of relationship exist between records in different data sets, such as ‘one to one’, ‘one to many’ and ‘many to many’. Choose only one type and give an example of this relationship. ...

How to find and store the number of times a user was part of a search criteria

LinkedIn provides a mechanism to say that the user was part of a search criteria "n" number of times in the last "x" days. How do you go about capturing and storing the information. Are you supposed to iterate the search results and put an appropriate counter whenever they get searched or is there a non-intrusive mechanism by which this ...

ASP.NET-MVC: Do Database Default Values Break The Spirit of Unit Testing?

Related Question My Question: In the key of ASP.NET-MVC - Do Database Default Values Break The Spirit of Unit Testing? ...

Need help in forumlating the query output in a certain fashion

We have a table which contains TV channel listings. create table listing (id, channel_name, event_name, event_time) a) listing (1, "ABC Channel", "All My Children", 6.00 AM) b) listing (2, "ABC Channel", "News", 7 AM) c) listing (3, "ABC Channel", "One life to live", 7.15 AM) d) listing (4, "ABC Channel", "General Hospital", 8.00 AM) e...

web application for data modeling

I am about to start development of a web based application and we need to create a data model for that. Is there any web based free and ready to go or *open sourc*e so I can install it on my linux server that allows collaboration application for data modeling? ...

storing multiple formats in a table

So here's the basic problem: I'd like to be able to store various fields in a database. These can be short textfields (maybe 150 characters max, probably more like 50 in general) and long textfields (something that can store a whole page full of text). Ideally more types can be added later on. These fields are group by common field_gro...