relational-database

How can I create an efficient MySQL database that auto-complete requests like Google

Hi! I'd like to get some ideas on how I can create an efficient MySQL database that can handle high traffic auto-complete requests like Google's new auto-SERP-update feature. The key to this is, I am trying to take the content of my book and I want to index the text in a way such that the database requests the relevant text in the qu...

Does anyone know of a tutorial for datamapper + sqlite3 with ruby?

I'm a newbie to programming & ruby (as well as datamapper & sqlite). I'm trying to figure out how to use all three but can't find any tutorials for beginners. Please let me know of tutorials or books. Thanks. ...

Microsoft Sync Framework error deleting foriegn key linked tables

I am using Microsoft Sync Framework 2.1 with SqlServerCE. I have a main table with a child table linked by a foriegn key. When I delete the main table entry, it fails since there are items in the child table (which have also been deleted.) How do I tell Sync what order to delete rows from tables in? ...

creating Models with sqlite3 + datamapper + ruby

How do you build a model with the following associations (i tried but couldn't get it to work): each Order has: a Customer, a SalesRep, many OrderLine that each has an item. I tried: when I do: Customer.all(Customer.orders.order_lines.item.sku.like => "%BLUE%") the output is :[] instead of: '[#<"Customer @id=1 @name="Dan Kubb">]' Whe...

The Relational Model & Queries That Naturally Return Duplicate Rows

It's commonly understood that in the relational model: Every relational operation should yield a relation. Relations, being sets, cannot contain duplicate rows. Imagine a 'USERS' relation that contains the following data. ID FIRST_NAME LAST_NAME 1 Mark Stone 2 Jane Stone 3 Michael Stone If someone runs a query se...

Does any one have a complete sample ruby program (with sources) using sqlite3 + datamapper

I've been trying to figure out how to use the datamappings in a real ruby program. After I code all of my mappings, then what? How do I use it in a real program? If any one has a sample program that I can look through the codes, it would help me out tremendously. Thank you. ...

What's the best way to design an Entity / Relationship Model?

For example if I have 20 tables, I have to design it by section? i.e CLIENT (id, name...) -- orders -- ODERS_DETAIL(id, products...) . . . lives --- ADDRESS(...) Or I can use The MySQL Workbench EER Model (To me, it looks like the Pysical Model)? Or like this: Data Modeling Levels ...

How large can the array passed to SQL where column_value IN (Array) be?

I am writing some code that will lookup for unique id's in a table with over 60,000 rows for the ones that are in an array using mysql_query("SELECT * FROM users WHERE unique_indexed_user_id IN('".join("', '", $array)."')") ; the amount of this array is not limited to the end user so they might end up selecting a large array. thus I...

Django model defining list of URLFields

I'm pretty new to relational databases and this may be why I'm having this problem but I have a model - Post. I want it to have variable number of URLs, however Django only seems to have the OneToManyField which requires a model (not a field - which URLField is). ...

NULL permitted in Primary Key - why and in which DBMS?

Subquestioning my question "Why to use “not null primary key” in TSQL?" [1] As I understood from other discussions, some RDBMS (for example, MySQL, SQLLite, which else?) permit "unique" NULL in primary key (PK). I read-read and could not grasp - why and what's for? Update: I believe it is beneficial for communication with other...

Database Performance Solution - "View Caching" - Is this a good idea?

Hi, A little context first: I would say I have good SQL server experience, but am a developer, not a DBA. My current task is to improve on the performance of a database, which has been built with a very heavy reliance on views. The application is peppered with inline sql, and using Tuning Advisor only suggests a couple of missing index...

Time table modeling in relational db

I know that it has been told almost anything related to time table modeling in RDBS, but i can not find any well written documentation about available techniques to store time tables in DB. My case: I have table witch holds available places, and table with actual classes. Each place has it's own unique schedule Each class can be sched...

Database Design: replace a boolean column with a timestamp column?

Earlier I have created tables this way: create table workflow ( id number primary key, name varchar2(100 char) not null, is_finished number(1) default 0 not null, date_finished date ); Column is_finished indicates whether the workflow finished or not. Column date_finished is when the workflow was finished. Then I had ...

Where is the best place to put validation logic given this application design?

Consider an ASP.NET MVC 2 web application project that uses EF4 POCO entities and the repository pattern to store information in a SQL Server database. So far there are 3 projects, 4 if you count the database: 1.) Domain.dll, has no dependencies, exposes POCO's and repository interfaces. 2.) Storage.dll, depends on Domain, implements ...

How can I check that two relational databases are identical regardless of primary keys?

I have a relational database with about 100 tables. Each table has unique, numerical, primary key with synthetic values and there are many foreign keys which link the tables. The tables are not big (tens or hundreds or records). This is a SQLite database. I need, for testing purposes, to compare two copies of the database by a linux scr...

Does every table really need an auto-incrementing artificial primary key?

Almost every table in every database I've seen in my 7 years of development experience has an auto-incrementing primary key. Why is this? If I have a table of U.S. states where each state where each state must have a unique name, what's the use of an auto-incrementing primary key? Why not just use the state name as the primary key? Seems...

Need help with Database Design

I have two Models - Users and Restaurants. They can set tweets like status messages and can have replies. i have the following setup and need your help to optimise the design. users(id, name, ......) restaurants(id, name.....) modules(id, name) [this table stores the modules - (1,user) and (2,restaurant) my message table status_mess...

Storing graphs in fully-normalized relational databases

I've nearly killed myself, multiple times, trying to find the perfect, flexible schema for storing many different types of objects with a wide variety of links between them in a relational database. But models such as EAV and things like polymorphic relationships just aren't true to relational databases. After learning about NoSQL graph...

What's the point of a candidate key?

I'm fairly new to database management and this question never seems to be answered in more than one sentence. All other SO answers say "A candidate key is a minimal super key." That means nothing to me. A candidate key is supposed to specify uniqueness of a db record, correct? And a primary key is a candidate key. If a primary key alrea...

Postgres inheritance for maintainability

Edit: TMI in initial question, cut to essentials. I'm thinking of a schema to support updating entries and version tracking. This is for a slowly changing dimensions scenerio, with a twist. To support the behavior I want, the basic schema is replicated three times: public tables, private tables, and change tracking tables This...