Questions tagged [relation]

A relation on sets S1, S2, ..., SN is any subset of S1 x S2 x ... x SN, where 'x' denotes the Cartesian product. In other words, a relation over N sets is any set of ordered N-tuples over the N sets.

A relation on sets S1, S2, ..., SN is any subset of S1 x S2 x ... x SN, where 'x' denotes the Cartesian product. In other words, a relation over N sets is any set of ordered N-tuples over the N sets.

1457 questions
12
votes
1 answer

Django Haystack: filter query based on multiple items in a list.

I have Event model instances that can belong to one or more Organization model instances. I've implemented haystack 2.0.0 to index all of my Events. Here is an example search index. class EventIndex(indexes.SearchIndex, indexes.Indexable): …
Joe J
  • 9,985
  • 16
  • 68
  • 100
12
votes
5 answers

Intersection of two relations

Say I have two relations that hold records in the same model, such as: @companies1 = Company.where(...) @companies2 = Company.where(...) How can I find the intersection of these two relations, i.e. only those companies that exist within both?
sscirrus
  • 55,407
  • 41
  • 135
  • 228
12
votes
2 answers

Why Projection Operator in relational algebra eliminates duplicates?

What are the consequences of eliminating duplicates in Projection Operator?And yes, why there is no duplicate elimination in real systems, unless specified?
Ashish
  • 358
  • 2
  • 4
  • 15
12
votes
4 answers

understanding the concept of Insertion Anomaly

I am learning insertion anomaly from www.sqa.org.uk/e-learning. Following data is written in it, An Insert Anomaly occurs when certain attributes cannot be inserted into the database without the presence of other attributes. For example this is the…
user379888
11
votes
2 answers

Laravel relationship not working: getConnectionName() Error

I have two tables users and user_details. I have linked users table as public function userDetails() { return $this->hasOne('App\Repositories\Models\UserDetails', 'id', 'user_id'); } and linked user_details table as public function user() { …
Tijan Manandhar
  • 322
  • 3
  • 18
11
votes
3 answers

In rubyonrails, how to get the associated model class from and ActiveRecord::Relation object?

Suppose I have an model: class Post end posts = Post.where(***) puts posts.class # => ActiveRecord::Relation Then how can I get the model class name through the variable 'posts', maybe some method called model_class_name: puts…
Croplio
  • 3,433
  • 6
  • 31
  • 37
11
votes
2 answers

Stub ActiveRecord::Relation with ActiveRecord objects

I'm not testing a Rails app. Just getting that out of the way. I'm testing a library that connects to a relatively active server, restricting records by timestamp. These returned records change as time goes on, making testing other restrictions more…
Brad Rice
  • 1,334
  • 2
  • 17
  • 36
10
votes
5 answers

yii2 gridview not showing all the left join values using hasMany retionship

Model Search : $query = Countries::find()->joinWith(['states']); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $dataProvider->setSort([ 'defaultOrder' => ['doc_date'=>SORT_DESC], ]); if…
sk2
  • 1,171
  • 1
  • 10
  • 28
10
votes
3 answers

Best practice to extend objects in underscore.js

I know that extending objects is done via the _.extend(parent, child); method. I've seen different places in the web where people are extending objects in a special way in underscore.js _.extend({}, this, child); Why do they do that?
Sebastian
  • 1,593
  • 4
  • 26
  • 41
9
votes
1 answer

In glsl, what is the formula used to compute gl_fragCoord from gl_position?

Please correct me if I'm wrong. When using vertex and pixel shaders, we usually provide the code to compute the output gl_position of the vertex shader. Then, we find ouselves with the input gl_FragCoord in the pixel shader. What are the name of…
wip
  • 2,313
  • 5
  • 31
  • 47
9
votes
2 answers

How to find sqlalchemy remote side object's class or class name without db queries?

Let's have a classes X and Y and relations between them x2y and y2x. From class_mapper(Class).iterate_properties iterator we can get all class's properties. So x2y and y2x are RelationshipProperty and what I hope to get from is a class or a class…
mdob
  • 2,224
  • 3
  • 22
  • 25
9
votes
3 answers

How to delete single (many-) rows from one-to-many relations in Laravel 5.5

I got two models in Laravel: Label class Label extends \Eloquent { protected $fillable = [ 'channel_id', 'name', 'color', ]; public function channel() { return $this->belongsTo('App\Channel'); …
andi79h
  • 1,087
  • 1
  • 12
  • 18
9
votes
1 answer

How can I help Clojure understand that 0 is the smallest natural number?

It's easy to define a lazy sequence of natural numbers in Clojure: (def N (iterate inc 0)). Unsurprisingly, if we ask Clojure to find the minimum of N using (apply min N), it gets stuck in an infinite regress. Is there a way to "build in" the fact…
9
votes
1 answer

dapper map one to one in classmapper

I have 2 simple tables. create table Owner ( Id int primary key, Name nvarchar(100), ); create table Status ( Id int primary key, BrandName nvarchar(50) OwnerId int foreign key references Owner(Id), ); In app I map these tables…
imodin
  • 821
  • 3
  • 12
  • 23
9
votes
3 answers

Relational Algebra - Cartesian Product vs Natural Join?

I am studying for exams and am failing to find a solid criteria by which I can determine if the Cartesian Product x is to be used or if Natural Join |X| is to be used. I had come up with a rough guide that: "If you need to project an attribute that…
Myles Gray
  • 8,711
  • 7
  • 48
  • 70
1
2
3
96 97