relational-database

What exactly is the problem with hierarchal and network models of databases?

Before E F Codd published his paper "A Relational Model of Data for Large Shared Data Banks" in 1970, hierarchal and network were the two prominent models of the database. What exactly was wrong with them that they did not prevail? ...

Normalized Database Question

I should know this but I expect it to be a simple answer... This is my simple database so far for this question: Am I supposed to insert the Id from Contact and Phone into Contact_Phone when I insert a record into Contact and Phone tables - or can this be done automatically? I am using SQL Server 2008 Express. ...

MySQL joins? What are they? When to use them?

I am probably going to get slaughtered for this, and told to read the manual (which I have, but it has not helped my understanding). I working with MySQL more and more at the moment, but I cannot get my head around joins, I know there are multiple types of join, i.e Inner, Outer, Left, Right but I do not what the differences are between...

Ways to join and update tables in SQL.

Hi, So I am a first time user here, and still relatively new to SQL. I am attempting to take 2 tables, and join them in a sense. In Table1 I have the data: House_Key ---Other Fields--- Customer_ID House_Key is not unique, and as such I can have multiple Customer_IDs per household. House_Key is a numerical code, and Customer_ID i...

Coming from a relational database background, how should I model relationships in db4o (or any object database)?

I'm experimenting with db4o as a data store, so to get to grips with it I thought I'd build myself a simple issue tracking web application (in ASP.NET MVC). I've found db4o to be excellent in terms of rapid development, especially for small apps like this, and it also negates the need for an ORM. However, having come from a SQL Server/M...

MVC 2 Application with a relational DB and object wrappers - how to get relational data into views?

I've recently refactored my application with the following: Linq to SQL db connection Objects to wrap the linq to sql classes Mappers to map back and forth between objects and Linq to Sql entitys Service layer to call the repository, handing up objects to the UI. Before I was just using Linq to SQL objects in my UI (I know). But when d...

Database Tagging with alternative Results

Hi, I'm working on an PHP/Jquery autosuggest tool that'll query a large table of tags but I need some suggestions for the db schema that'll return related tags as well as match-based results. For example: I type 'Web': Results 'Web Developer' 'Web Designer' 'Web Analyst' and also related tags... 'PHP Developer' 'Flash Program...

MySQL: Getting connected (simillar) data with lef/right fields

In MySQL Im having two tables: PRODUCTS (id, Name) SEEALSO (id, prodLeft, prodRight) SEEALSO defines which PRODUCTS are related together and are represented as binded fileds "prodLeft"-"prodRight". For Example: PRODUCTS: 1 Desk 2 Table 3 Chair 4 Doors 5 Tree 6 Flower SEEALSO 1 1 2 2 2 3 3 3 4 4 5 6 From that we can see bin...

Django: Caching aggregate query?

I've got an Invoice model, and I want to keep the total up to date. So I've added a property like this @property def item_total(self): if not hasattr(self, 'item_total_cache'): self.item_total_cache = self.items.aggregate(t=Sum('amount'))['t'] return self.item_total_cache Because item_total might get called a few times...

Django unique constraint + form errors

I'm having some issues with double-posting on my site. I figure a simple unique constraint across all the relevant fields will solve the issue on a database level, but then it just produces a nasty error page for the user. Is there a way I can turn this into a pretty form error instead? Like a non_field_error? Or what approach should I t...

Documenting relational databases (tables, views, functions, triggers)

I'm trying to improve the knowledge management of MySQL structures available on a project. By structure, I mean tables, views, functions, procedures, triggers. All these structures are extracted in .sql files. I'm looking for a way to document these structures, presenting results à la doxygen in HTML files. For example, I want this too...

php: Creating automatic database sharding logic?

Hi everybody, I did just come up with the following idea, but I lack the knowledge to say if it is applicable to a production application. We have a web application, built on PHP/mySQL to make it easy. A table in the database are prone to grow large - a couple million of records easily, so table sharding might be an option here. Here...

What is the maximum physical table size in Oracle?

Is there some limit on the maximum total amount of data that can be stored in a single table in Oracle? I think there shouldn't be because tables are anyways stored as a set of rows and rows can be chained as well. Does such a limit exist? ...

How to create a relational Schema with following tables?

Hi Currently I have three tables. GrandParent( tel int, G_Counter int, GField varchar(10)); Parent( tel int, G_Counter int, P_counter int, PField Varchar(5)); Child(tel int, G_counter int, P_counter int, C_Counter int, CField Varchar(3)); These tables are all flat tables. And these tables loop itself and the loop is determined by the...

Rails -- How to setup model that can belong to either of 3 different models

I'm trying to make an app that does testing similiar to what you would experience in school. I have a model Question, which can belong to either an Exam, Quiz, or Assignment. Should I create fields for ":exam_id, :integer, :null => false; :quiz_id, :integer, :null => false; :assignment_id, :integer, :null => false;"? The question w...

Which database(s) should I use?

Hi, I'm building an application that needs to query a lot of data that is written once and not changed anymore. Should I use MySQL for that or should I use something like SimpleDB or BigTable? (I need to write once, read many times) Thank you. Edit: I want to use Heroku, big for me is more than 5MB. "Thousands of rows" take more than ...

Are all modern RDBMS row oriented? Why?

If one of relational databases paradigms is to be tuple oriented we have the biggest limitation here. If one could design column oriented db, that would improve performance a lot. Vector operations would perform out of the box, indexing, hashing for simple symbol columns lookups, linked lists behind the scenes as engine. Memory mapping...

How should I represent a unique super-admin privilege in a database?

My project needs to have a number of administrators, out of which only one will have super-admin privileges. What is the best way to represent this in the database? ...

Can I (theoretically) use a Collection (e.g., Array, List) as a foreign key in a relational Database schema?

Is is possible to use a Collection such as a Multiset or Array as the foreign key in a database scheme? Background: A student proposes to use such a construct (don't use a join table for the n:m association) to store the following object structure in a database public class Person { String name; List<Resource> res; … } pu...

Database schema dilemma with foreign keys pointing to multiple tables (exclusive arc)

Hopefully my description is a little better than the title, but basically I'm having an issue with one part of a new application schema and i'm stuck on what is the most manageable and elegant solution in table structure. Bare bones table structure with only relevant fields showing would be as follows: airline (id, name, ...) hot...