Is this a many to many relationship?

So i have one table of data, each data object has two owners from the
users table.

so it’s

data table

id owner1_id owner2_id

5 1 2
10 1 2

owner table

id name

1 bob
2 cornholio

so when i pull records from the data table for owner1_id how would i
access the name field of owner id 2?

You need three tables to represent a many-to-many association.

class Owner < ActiveRecord::Base
has_and_belongs_to_many :datas
end

class Data < ActiveRecord::Base
has_and_belongs_to_many :owners
end

Table owners:

id: integer
name: string

Table datas:

id: integer
value: integer

Table datas_owners:

data_id: integer
owner_id: integer

This is shown using the more basic has_and_belongs_to_many (HABTM)
associations. However, in some cases it’s necessary to store
additional information in the join table managing your many-to-many
association. In which case your can make the join table into model
class and use has_many :through.

Having owner1_id, owner2_id is in violation of the “First Normal Form
(1NF)” relational database rule.

On Aug 1, 12:07 am, Morgan M. [email protected]

Robert W. wrote:

Having owner1_id, owner2_id is in violation of the “First Normal Form
(1NF)” relational database rule.

First normal form - Wikipedia

On Aug 1, 12:07�am, Morgan M. [email protected]

the owner1_id corresponds to the student associated with the entry.
the owner2_id corresponds to the teacher associated with the entry.

i just used the owner1 and 2 for sake of simplicity.

there is a table of students and teachers with a user level to decide
what they are thats used for basic information and authentication. it
seemed more logical to treat it that way… please correct me if i’m
wrong… i’m a little tarded when it comes to database design.