Let's say I have two tables:
Report
Comment
And assuming I have a database context:
var reports = db.Reports();
How can I make sure all Comments for each report are loaded as well?
At this point I want to disconnect from the database but still
have access to the comments. (For example:)
reports[0].Comments[0].Subject
...
Hello!
I am writing a addressbook module for my software right now. I have the database set up so far that it supports a very flexible address-book configuration.
I can create n-entries for every type I want. Type means here data like 'email', 'address', 'telephone' etc.
I have a table named 'contact_profiles'.
This only has two colu...
Summary:
I have a table that has a uique primary key identifying each record. I also have three more fields that can identify a record:
Category
CategoryNumber
DuplicateNumber
When I add a new record and choose the Category, how can I get CategoryNumber to increment correctly based on whether it is a duplicate or not.
Note that thi...
I'm trying to wrap my head around xml schemas and one thing I'm trying to figure out is how to do relational type schemas where on element refers to another, possibly in another schema altogether. I've looked at the xsd:key and xsd:keyref and it seems like the sort of thing I'm interested in, but I'm not sure. Initially I just set attrib...
I'm reading CJ Date's SQL and Relational Theory: How to Write Accurate SQL Code, and he makes the case that positional queries are bad for example, this INSERT:
INSERT INTO t VALUES (1, 2, 3)
Instead, you should use attribute-based queries like this:
INSERT INTO t (one, two, three) VALUES (1, 2, 3)
Now, I understand that the first...
Hello,
First of all, excuse my poor topic title. I simply have no idea how to formulate this question or what to Google after, so don't shoot me if this is something easy answerable.
Assume I have the following tables:
[AUTHORS] id, name
[NEWS] id, item, author_id
If I wanted to display a news item and output the corresponding autho...
this my question i dont know what to do
Let A =
{1, 2, 3, 4, 6} and let R be the binary relation on A defined by“x divides
y”. (x divides y if and only if there exists an integer z such that xz = y).
i. Write R as a set of ordered pairs.
...
table user:
|id|name|employee_priority_id|user_priority_id|
table priority:
|id|name|
As you can see, there are two foreign fields to the same table. But Kohana ORM default looks for a field called priority_id, which doesn't exist.
Is there a way to let Kohana ORM know that those two fields are an foreign key to that table.
...
Just working on a project where I have a class called 'Product' and a class called 'Image'. Each product has two types of images, one 'front' image and one 'back' image, so I defined two fields, one called image_front_id and one called image_back_id.
In the method BaseProduct::setUp(), I defined the relation for the front images as foll...
Hi everyone!
Can anyone give me an example of how to implement a class self-relation?
Thanks in advance,
Best regards!
...
I'd like to model the following relationship.
[JoinedBase]
MasterForm{
Guid MasterFormId {get;set;}
/* some base properties like modifiedBy etc... */
}
[ActiveRecord]
TerminationForm{
[PrmaryKey(Foreign)]
Guid MasterFormId {get; set;}
/* Some more properties specific to terminations */
}
[ActiveRecord("TermStaffing")]
...
I was following the screencast on rubyonrails.org (creating the blog).
I have following models:
comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
validates_presence_of :body # I added this
end
post.rb
class Post < ActiveRecord::Base
validates_presence_of :body, :title
has_many :comments
end
Relations ...
Hello,
I have 3 tables: A, B and C.
Table A is in relation (n:1) with B and with C.
Typically I store in A the B.Id (or the C.Id) and the table name.
e.g.
A.ParentId = 1
A.TableName = "B"
A.ParentId = 1
A.TableName = "C"
A.ParentId = 2
A.TableName = "B"
Is it a good solution? Are there any other solutions?
Thanks in advance
...
Table tags:
article_id tag
1 Language
1 Java
1 c++
2 Language
2 c++
3 c++
and how can I write SQL(s) query(s) to make the data like below:
Table tags_relations:
tag1 tag2 relations_degree
Language C++ 2
Language Java 1
note: if...
In EF eager loading related entities is easy.
But I'm having difficulties including inherited entities when loading data using table-per-type model.
This is my model:
Entities:
ArticleBase (base article entity)
ArticleSpecial (inherited from ArticleBase)
UserBase (base user entity)
UserSpecial (inherited from UserBase)
Image
R...
I've got a problem with a belongsTo relationship in CakePHP.
I've got an "Action" model that uses the "actions" table and belongs to one of two other models, either "Transaction" or "Tag". The idea being that whenever a user completes a transaction or adds a tag, the action model is created to keep a log of it. I've got that part workin...
Hi!
We're drawing up the database structure with the help of mySQL Workbench for a new app and the number of joins required to make a listing of the data is increasing drastically as the many-to-many relationships increases.
The application will be quite read-heavy and have a couple of hundred thousand rows per table.
The questions:...
Hi,
so..I followed doctrine documnetation to get started. Here is the documentation
http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relations:retrieving-related-records
My code is
$User = Doctrine_Core::getTable("User")->find(1);
when I access relations by $User->Phonenumbers, it works. ...
What I am trying to do is kind of like this:
I have datatypes "user" and "article" for instance. I want to have relationships between these two, but in more than one way.
So for instance, I'd like to let a user "like" or "bookmark" an article. So I need to have two relations in the database, one for users liking the article, and one fo...
I have a table called "restaurants" which contains each restaurant information, I want to add its phone numbers.
Should I make another table called say "phones" with fields "phone1", "phone2", "phone3", etc, then make a relation between them? or their is an easier way to do this?
Thanks a lot :)
...