relational

What are the better ways with INSERT on relational tables?

I'm experiencing my first mysql INSERT tests and I'm using these tables: table employees -> employee_id -> employee_name -> employee_surname -> employee_url table areas -> area_id -> area_city -> area_address -> area_country table agencies -> agency_id -> agency_name -> agency_url table node_employees -> node_id -> employee_id -> are...

Tuple relational calculus

Is safe tuple relational calculus a turing complete language? ...

What will be the best way to keep track of modified tuples in a database?

I am currently working on a project in which I have to keep track of the tuples that are modified in a relational database. This should include updated tuples, but also inserted and deleted tuples. My question is what will be the best way to accomplish this? I have several ideas of my own, but maybe there are easier/better ways that I di...

How to structure database for relational? data

I need to keep track of points scored and who they are scored against. Previously, I did this using a flat file database (that was a mess) that looked like this: 03611100025 00001000000 21011000000 00003000000 00021000000 10001050000 00001402000 00001000100 00001013050 00001000100 00001000000 Each team got a row and a column, and I gu...

Relational algebra - what is the proper way to represent a 'having' clause?

Yes, this is a homework question but the names have been changed to protect the innocent. Meaning, I am not asking the homework question itself, but rather a small part of it so I can understand the whole. Let's say you have a SQL query like this: --The query would list car prices that occur more than once. select car_price from cars ...

Design question for highly extensible project - Bearing in mind best practises.

Hi there. Development environment is C# 3.5 with a SQL Server 2008 database and Entity Framework. Imagine you have a class and a table called Sign which represents a physical electronic sign created by a third party which your software needs to control. You also have a class called SignDriver which takes care of actually communicating ...

Exclude rows with Doctrine ORM DQL (NOT IN)

I'm building a chat application with codeigniter and doctrine. Tables: - User - User_roles - User_available Relations: ONE user have MANY roles. ONE user_available have ONE user. Users available for chatting will be in the user_available table. Problem: I need to get all users in in user_available that hasn't got role_id 7. So I ...

Terribly slow SQL query with COUNT and GROUP BY on two columns

I'm archiving this web forum, which normally gets purged about once a week. So I'm screen scraping it, and storing it into my database (PostgreSQL). I also do a little analysis on the data, with some graphs for users to enjoy, like what time of day is the forum most active, and so forth. So I have a posts table, like so: Column |...

Insert 2 rows that are related in both directions in SQL

I have two tables kinda like this: // Person.Details Table: PersonID int [PK] | EmployeeCreatorID int [FK] | FirstName varchar | OtherInfo... // Employee.Details Table: EmployeeID int [PK] | PersonID int [FK] | IsAdmin bit | OtherInfo... Each table is related to the other: [Employee.Details.PersonID]===>[Person.Details.PersonID] AND...

mysql query normal relationship table vs concatenated realtionship table

I have a question about relationships between two tables. Let's say we have a table users, and links. users +++++++++ id name 1 name1 2 name2 3 name3 +++++++++ links +++++++++ id link 1 link1 2 link1 3 link1 +++++++++ Now the normal way to link these two is with a name_links table. For example: name_links ++++++++++++ uid ...

EF pulling out reference primary keys in a 1-M relationship...

Hi guys In a 1-M relationship, in the many side of the relationship I can pull out the Id of the parent item without doing another query using something like the following: this.ParentReference.EntityKey.EntityKeyValues[0].Value But what I am wondering if there a similar way of pulling out the many ID's from the 1 without doing anot...

historically, what made relational databases popular?

EDIT I've just started skimming Codd's famous 1970 paper that started it all, that Oracle was based on (A Relational Model of Data for Large Shared Data Banks [pdf]), and was amazed to find that it seems it will answer this SO question. It talks about databases in the market at that time ("hierarchical" and "network" - like NoSQL?), the...

Best Way to handle Relational Data in CodeIgniter?

When creating a CodeIgniter project, what is the best way to handle relations between models? Should models contain other models that they are related to, should this be handled in the controller, or is there some other way to handle these scenarios? I'm thinking about one-to-one, one-to-many, or many-to-many relationships. example: let...

How would I find the highest/largest of something with relation algebra, domain relational calculus and tuple relational calculus

This is part of a homework assignment. I've got several questions asking find the eid of the employee with the highest salary, or 2nd highest salary. Find the pilot that is certified for the most aircrafts. I don't have any idea on how to do it. There aren't any examples in the chapter, and google is proving less that helpful. If someone...

Help to translate SQL query to Relational Algebra

Hi everyone, I'm having some difficulties with translating some queries to Relational Algebra. I've a great book about Database Design and here is a chapter about Relational Algebra but I still seem to have some trouble creating the right one: Thoes queries I've most difficuelt with is these: SELECT COUNT( cs.student_id ) AS counter F...

I have a KVP Key value pair Table, Need sql to make it relational structure...!

I have a KVP Table and the structure is ID, Key, Value and below are the sample values.... Table with values ID , Key, Value 1 , STATUS, TRUE 1, AGE GROUP, 10 1, TRAVEL, Y 2 , STATUS, FALSE 2, AGE GROUP, 20 2, TRAVEL, N I want these date to transform as below (Output) ID , STATUS, AGE GROUP, TRAVEL 1, TRUE , 10, Y 2, FALSE, 20, N ...

Can someone describe the nested set model from a C#/LINQ perspective?

I know the nested set model doesn't pertain to the C# language or LINQ directly... it's what I'm using to develop my web app. For hierarchical data (categories with sub-categories in my case), I'm currently using something similar to the Adjacency List model. At the moment, I've only got 2 levels of categories, but I'd like to take it f...

Software to find dependencys in a database that not have them as restrictions

I have a database in SQL server 2005 that originaly comes fom an old mainframe. All relations was set in the surrounding software and there are non i the database. I need to find the relations, not by field name but by actual contence in the registers. (as suggestions, I realize I'l have to check them up) It would be nice with some ext...

Database - Designing an "Events" Table

After reading the tips from this great Nettuts+ article I've come up with a table schema that would separate highly volatile data from other tables subjected to heavy reads and at the same time lower the number of tables needed in the whole database schema, however I'm not sure if this is a good idea since it doesn't follow the rules of ...

Limit a user to view only associated records in rails

I have an application with three Models (Profile -> SubModel -> SubSubModel) chained together with has many relationships. I am trying to limit a user, after logging in, to only retrieving records that are associated with their Profile. I am very new to rails and this is what I had been trying in the Profile model has_many :submodels, :...