relational-database

What is the best database for my needs?

I am currently using MS SQL Server 2008 but I'm not sure it it is the best system for this particular task. I have a single table like so: PK_ptA PK_ptB DateInserted LookupColA LookupColB ... LookupColF DataCol (ntext) A common query is SELECT TOP(1000000) DataCol FROM table WHERE LookupColA=x AND LookupColD=y AND LookupColE=z ORD...

Storing connections between people in a MySql database

I would like to create a database where I store the links between people. I then need to bring back the records detailing which people are connected to which others. I need to output: person1 is connected to person2 is connected with person3 etc. How can I get started with this task? ...

When are ENUMS joined in in PostgreSQL

If I run a select from a column in PostgreSQL that is of type enum, are the string values of the enum joined in before or after the final result set has been created? An explanation of my motive can be found at http://archives.postgresql.org/pgsql-performance/2008-07/msg00226.php ...

Is MongoDB a valid alternative to relational db + lucene?

On a new project I need a hard use of lucene for a searcher implementation. This searcher will be a very important (and big) piece of the project. Is valid or convenient replacing Relational Database + Lucene with MongoDb? edit: Ok, I will clarify: I'm not asking about risk, I can pay that price in this project. My point is: Is MongoDB ...

Should this even be a has_many :through association?

A Post belongs_to a User, and a User has_many Posts. A Post also belongs_to a Topic, and a Topic has_many Posts. class User < ActiveRecord::Base has_many :posts end class Topic < ActiveRecord::Base has_many :posts end class Post < ActiveRecord::Base belongs_to :user belongs_to :topic end Well, that's pretty simple and very...

SQL: How do I INSERT primary key values from two tables INTO a master table.

Hello, I would appreciate some help with an SQL statement I really can't get my head around. What I want to do is fairly simple, I need to take the values from two different tables and copy them into an master table when a new row is inserted into one of the two tables. The problem is perhaps best explained like this: I have three ta...

How should I manage my many-to-many relationships?

Hello all, I have a database containing a couple tables: files and users. This relationship is many-to-many, so I also have a table called users_files_ref which holds foreign keys to both of the above tables. Here's the schema of each table: files -> file_id, file_name users -> user_id, user_name users_file...

Relational Database arrays (H2, Java)

I seem to have two options on how to implement arrays, and I want to know which I should go with: Use the ARRAY data type and (from what I understand) effectively serialize data objects into the database (which in my case are just wrapped primitive types; don't know of another way to make this work). Use a separate table and map with f...

Representing Sparse Data in PostgreSQL

What's the best way to represent a sparse data matrix in PostgreSQL? The two obvious methods I see are: Store data in a single a table with a separate column for every conceivable feature (potentially millions), but with a default value of NULL for unused features. This is conceptually very simple, but I know that with most RDMS implem...

django models : How to have variable number of foreign keys in a model ?

For instance, Model Resume contains variable number of Model Project 's, What should be my models and relationships between them to achieve this ? Thanks in advance. ...

Class Table Inheritance vs. Denormalization

I'm trying to model a specialization/generalization, leaning towards using class table inheritance (see this answer). However, my co-worker has maintenance and performance concerns because there will be many (50+) overlapping specializations of the same table. His suggestion is to create a table with the following columns: Reference t...

C# Importing Large Volume of Data from CSV to Database

What's the most efficient method to load large volumes of data from CSV (3 million + rows) to a database. The data needs to be formatted(e.g. name column needs to be split into first name and last name, etc.) I need to do this in a efficiently as possible i.e. time constraints I am siding with the option of reading, transforming an...

Storing dates i Train schedule MYSQL

Hi I have created a train schedule database in MYSQL. There are several thousand routes for each day. But with a few exceptions most of the routes are similar for every working day, but differ on weekends. At this time I basically update my SQL tables at midnight each day, to get the departures for the next 24 hours. This is however v...

How do get a ID from one table in phpMyadmin and add it to another table field on insert

Hi, I am try to add id from one table to another table to give a relationship to the tables. I am doing this on a number of tables on insert of data from a form. Example: person owns and item so item has item and person ids to link the two, however in some cases I have optional tables so sometimes the ids of those tables will be added ...

Database that consumes less disk space

I'm looking at solutions to store a massive quantity of information consuming the less possible disk space. The information structure is very simple and the queries will also be very simple. I've looked at solutions like Apache Cassandra and relations databases but couldn't find a comparison where disk usage is mentioned. Any ideas on ...

Synonym for "Many-to-Many" relationship (relational databases)

What's a synonym for a "many-to-many" relationship? I've finished writing an object-relational mapper but I'm still stumped as to what to name the function that adds that relation. addParent() and addChild() seemed quite logical for the many-to-one/one-to-many and addSuperclass() for one-to-one inheritance, but addManyToMany() would sou...

relational databases and multicast messages

I have read that relational databases are a terrible way to do multicast messages like twitter. So twitter saves every tweet only one times and then retrieve its in every stream ? or saves every tweet in every users's stream ? I want to know why relational database ( like mysql or postgresql ) doesn't good for twitter-like application....

Foreign key on a child table dependant on parent field

Using SQL2005/2008. Let's say I have a Hotel table (HotelID, HotelName) and a Room table (RoomID, HotelID, RoomName) Hotel -> Room 1:M by HotelID RoomID is PK inside Room Now I have a Contract table (ContractID, HotelID, ContractDescription) and ContractRate (ContractRateID, ContractID, RoomID, Rate) All primaries and foreign key...

MySQL - Accessing all relational data in one query

I have a relation mysql database setup. and I want to pull all the data for one item from the main row and all the relational data (ie multiple associated rows) in one query. What's the easiest/best way to do this aside from a multiple JOIN statement in one query? The tables and query currently used are below. Relational data --------...

mysql Delete and Database Relationships

If I'm trying to delete multiple rows from a table and one of those rows can't be deleted because of a database relationship, what will happen? Will the rows that aren't constrained by a relationship still be deleted? Or will the entire delete fail? Thanks, Colin ...