Questions tagged [relationship]

Questions in this tag typically involve the association that a set of data has with other set(s) of data.

5577 questions
56
votes
2 answers

What rel=profile is for?

While doing the HTML for my new template, I stumbled across a new meta tag What's this for? I found it linking to this page, and through Google I found this Microformat but I didn't get it.
Omar Abid
  • 15,753
  • 28
  • 77
  • 108
49
votes
3 answers

How do I access the properties of a many-to-many "through" table from a django template?

From the Django documentation... When you're only dealing with simple many-to-many relationships such as mixing and matching pizzas and toppings, a standard ManyToManyField is all you need. However, sometimes you may need to associate data with the…
Alex
  • 2,350
  • 2
  • 20
  • 17
46
votes
9 answers

How to find all the relations between all mysql tables?

How to find all the relations between all MySQL tables? If for example, I want to know the relation of tables in a database of having around 100 tables. Is there anyway to know this?
user3148861
  • 461
  • 1
  • 4
  • 3
41
votes
3 answers

Determine Which Objects Reference a Table in SQL Server

I need to rename a table that has many columns and stored procedures that process against that table. How can one get all Items in database that have a relation to a table in such a scenario?
Tavousi
  • 14,848
  • 18
  • 51
  • 70
41
votes
6 answers

Laravel relationships in migrations?

I know you can define table relationships fairly easy with $this->belongs_to(), $this->has_many() etc, but what i don't understand is how the relationship table is created; the table that binds the two tables together (i forgot what the term is…
qwerty
  • 5,166
  • 17
  • 56
  • 77
39
votes
4 answers

Laravel Polymorphic Relations Has Many Through

I have a Subscriber model // Subscriber Model id user_id subscribable_id subscribable_type public function user() { return $this->belongsTo('App\User'); } public function subscribable() { return $this->morphTo(); } And a Topic model //…
Edward
  • 421
  • 1
  • 4
  • 5
38
votes
7 answers

Laravel check if relation is empty

I have an object with some relationships and I need to check if these relations are empty or not, I'm trying to check with is_null, isset, != undefined, etc but nothing works, here is the relationship I get when it's empty…
Spialdor
  • 1,475
  • 5
  • 20
  • 46
38
votes
1 answer

Elasticsearch relationship mappings (one to one and one to many)

In my elastic search server I have one index http://localhost:9200/blog. The (blog) index contains multiple types. e.g.: http://localhost:9200/blog/posts, http://localhost:9200/blog/tags. In the tags type I have created more than 1000 tags and 10…
Aruljothi
  • 497
  • 1
  • 6
  • 14
37
votes
2 answers

Neo4j Bidirectional Relationship

Is there a way to create bidirectional relationship in Neo4j using Cypher? I would like the relationship to be bidirectional rather than making two unidirectional relationships in both directions For eg: (A)<-[FRIEND]->(B) Rather…
sgp
  • 1,738
  • 6
  • 17
  • 31
32
votes
1 answer

Get ids array from related laravel model which is having belongsToMany relationship

I have a model Role which belongs to many Users. Class Role { public $fillable = ["name"]; public function users() { return $this->belongsToMany('App/Models/User')->select(['user_id']); } } When I retrieve users…
sp11
  • 323
  • 1
  • 3
  • 6
31
votes
4 answers

How to define two relationships to the same table in SQLAlchemy

I’ve looked all over the SQLAlchemy tutorial and other similar questions but I seem to be struggling to get this join to work: The scenario: I have a pages table represented by the Page model. Pages can be created by an user and edited by an user,…
richzilla
  • 40,440
  • 14
  • 56
  • 86
31
votes
3 answers

How to view database diagram in a Code First using localdb

I have a Code First project with Entity Framework 5.0.0 using localdb created in Visual Studio 2012 Ultimate. Although I can see my class relations in a Class Diagram, how to see a visual diagram of automatic generated database by EF ?
Xaqron
  • 29,931
  • 42
  • 140
  • 205
30
votes
5 answers

Add record to a has_and_belongs_to_many relationship

I have two models, users and promotions. The idea is that a promotion can have many users, and a user can have many promotions. class User < ActiveRecord::Base has_and_belongs_to_many :promotions end class Promotion < ActiveRecord::Base …
30
votes
1 answer

MySQL - How to insert into table that has many-to-many relationship

I have a table of persons. Each person has a property and many persons may have a certain property. So this is a many-to-many relationship. This is the schema: CREATE TABLE persons ( person_id int(11) NOT NULL AUTO_INCREMENT, firstname…
Christos Baziotis
  • 5,845
  • 16
  • 59
  • 80
28
votes
4 answers

Laravel whereDoesntHave() - multiple OR conditions

In Laravel 4.2 I have a model called Product with many-to-many relationshis to other models like Country or Category. I want to filter out products that are "incomplete", which means they have no connected countries or no connected categories. I can…
KazikM
  • 1,257
  • 5
  • 21
  • 29