relational

Tuple Relational Calculus or Relational Algebra Syntax verifier?

Does anybody knows of a software package where you can type a formula and it verifies sintactically (it doesn't need to check semantics). Thanks. ...

Ruby on Rails: One to many relationship view

New to rails and trying to get a one to many relationship up and running. I have it working in the Model and Controller, but I'm having trouble getting it up and running in the views. class Project < ActiveRecord::Base has_many :non_labor_expenses end class NonLaborExpense < ActiveRecord::Base belongs_to :project end I manually c...

RDBMS data-relation burden

Our in-house system is built on SQL Server 2008 with a 40-table 6NF schema. Most of the tables FK to 3 others, a key few as many as 7. The system will ultimately support 100s of employees working with 10s of 1000s of customers and store 100s of 1000s of transactional records -- prime-time access should peak at 1000 rows per second. Is...

rails average between multiple models

I've been trying to get my head around doing things using my Rails relationships as opposed to pulling out large SQL joins, but I can't wrap my head around this one... I have 3 models Hotels Rooms Availables They all have the appropriate has_many and belongs_to relationships. What I want to do is on the overview page listing th...

database structure

I'm building a gambling-related website where people can be on soccer fixtures (matches). A fixture ends up with a result: home win - draw - away win. I have one table for teams and one table for fixtures and another for bets. The fixtures table has a home team and an away team. But how do I model a draw bet? It's easy to have the bet t...

SQL selecting rows where one column's value is common across another criteria column

I have a cross reference table that looks like this: id document_id subject_id 1 8 21 2 5 17 3 5 76 4 7 88 5 9 17 6 9 76 7 2 76 It matches documents to subjects. Documents can be members of more than one subject. I want to return rows from thi...

Modelling data loading techniques for a MVC web application

Hi all, When you are developing an MVC based website that will, for instance, be able to display profile information about a user, how do you usually model data if it's coming from a relational database so that it would still be useful if the persistent storage mechanism changes (perhaps to some SOAP or XML based webservice)? For examp...

Database relation many to many

This is basicly my database structure one product (let say soap) will have many retail selling size 1 liter 4 liters 20 liters In my "produit" database I will have the soap item (id #1) In the size database i will have many size availible : 1liter 4liter 20liter How not to duplicate the product 3 time with a different size....

Best Practice for relationships shared among multiple tables

I keep running into this design problem, and I'm not happy with my solution so far. The problem is this: I have two or more entities, like People and Dogs, and they both have a relationship with a Notes table, that stores a message field and some meta data about the message like maybe the author. 1) First option is to not enforce the ...

SQL Server 'object'/'property' relational tables linking to other tables

Excuse the poor title, i can not think of the correct term. I have a database structure that represents objects, objects have types and properties. Only certain properties are available to certain types. i.e. Types - House, Car Properties - Colour, Speed, Address Objects of type car can have both colour and speed properties, b...

mysql - query three tables

I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which gives all results from the third table that relate to it? Sorry I am...

mySQL - Insert into three tables

I recently asked this question. I have a relational database with three tables. The first containts id's that relate to the second. The second contains id's that relate to the third. The third contains the results I am after. Is it possible with a single query to query an id in the first table which g...

MySQL: inserting records in tables linked by foreign key

In MySQL, is it possible to have two tables linked by a foreign key and when a record is inserted into the parent table to create a corresponding record in the child table? I have a website that handles member registrations. One table contains the member's details such as name and email address, and is linked to a settings table via mem...

How to store word compositions in a relational database in a normalized way?

I'm trying to find a nice way to store word compositions of the following form: exhaustcleaningsystem exhaust cleaning system exhaustcleaning system exhaust cleaningsystem The combinations are given by a default per case. Every word in a composition is stored as a unique row in table 'labels'. labels id value --------------------...

SQL design for survey with answers of different data types

I am working on an online survey. Most questions have a scale of 1-5 for an answer. If we need to add a question to the survey, I use a simple web form, which does an INSERT into the appropriate table, and voila! surveys are asking the new question -- no new code or change to the database structure. We are being asked to add survey ques...

How can I access the last inserted row ID within a SQL script?

I'm using SQLite, and I have a table for properties, and a table for sub-properties. Each sub-property points to its parent using the fkPropertyId column. Right now, to create the initial database, I've got a script that looks something like this: INSERT INTO property VALUES(1,.....); INSERT INTO property VALUES(2,.....); INSERT INTO ...

What's the best relational structure for implementing a FIFO product inventory?

What's the best relational structure for implementing a FIFO product inventory? I need that the product entries be stored grouped by entry date and entry price, but sales from the existing stock be made in a First-In-First-Out manner, in which the product quantity representing the sale would be subtracted from the oldest entries first. T...

'questions' and 'answers' with multiple answers

This question is related to this post: http://stackoverflow.com/questions/1764469/sql-design-for-survey-with-answers-of-different-data-types I have a survey app where most questions have a set of answers that are 1-5. Now we have to do questions that could have a variety of different answer types -- numeric, date, string, etc. Thanks to...

Do I need an ORM for simple related queries in PHP/CI?

I started my app very simply following the documentation videos for Codeigniter. I have the following tables: Account account_id name details Contact contact_id account_id name address Order order_id account_id contact_id date description Item item_id order_id description ...

Relations via magic-table

I encountered an interesting SQL table (column names listed): From_TableName | From_Id | To_TableName | To_Id From what I understood, this table is used for all table relationships in the database. There's not a lot of data (more than 10000 lines in the previously mentioned table) in the database, so, I guess, performance was not that i...