MYSQL Relationship....Not Clear - mysql

Is this a one-to-one or one-to-many relationship?
I think it is one-to-many as one sales rep can serve many customers. But in this select statement case, i am confused.

Related

What are table relationships for [SQL]?

I have really dumb question...,
for what are exactly relationships in databases?
If I selecting data from two tables for example:
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
In query is exactly specified the columns of what tables will be connected to each other.
Result will be same, no matter if I use foreign keys.
Maybe I am not enough good to find answer, but everywhere is explained HOW to use them, but not WHY I should use them.
PS.: Sorry for bad English, google translator did a lot. :)
Relationships in Databases are used to maintain connection between two entities. For example : classes table and Teachers table. a teacher can take more than one class which means there is a one to many relationship here and by separating data into two separate entities help to maintain referential integrity

SQL entities , multiple relationship

ER sketch
is it possible to have this kind of relationship with 2 entities, was told that these will make data duplication problems
THANK YOU
Yes, It is possible to create more than one relationship between two entities. For example works for and managed by are two relationships between the entities Employee and Department. works for relationship is used to represent the department that which he is working, and managed by relationship is used to represent the manager of a department. Note that manager is also an employee.

Laravel 4 distant Eloquent relations

I'm trying to eager load a distant relation using Eloquent and am running into problems. There are 5 tables involved, they are users, corporate_users, corporations and two Sentry tables (groups and users_groups).
The tables are setup as follows:
Users hasOne CorporateUsers (one-to-one)
CorporateUsers belongsTo a Corporation (many-to-one)
Users have a many-to-many relationship with groups through the users_groups pivot table.
All of these relationships work individually. Initially I could get around the distant relation problem by calling CorporateUsers::with(array('user', 'corporations')); because CorporateUsers have a direct relation with both Users and Corporations.
My problem is that I how to setup the relationship between CorporateUsers and Groups, through the pivot table users_groups which references user_id and not corporate_user_id? I've tried the hasManyThrough relationship but it wasn't working.
Anyone have any advice?
You use dot notation for nested relationships. It should make your life easier.
CorporateUsers::with('user.groups', 'corporations')->get();

When or use a many-to-many relation in a database?

I want to know in what situations we create many to many relation. What is the need of doing such?
A quick search goes a long way. Though the following is for MS Access, the concept is the same for any relational database.
Via: office.microsoft.com - Create a many-to-many relationship:
You have a many-to-many relationship when a single record in one table
can relate to many records in another, and a single record in that
second table can also relate to many records in the first. For
example, say your company has several types of computers and several
technicians, with each technician certified to work on some, but not
all, of the computers. Each technician can be related to more than one
computer, and in turn, each computer can be related to more than one
technician.
To track who can work on a given machine, you create a many-to-many
relationship by adding the primary keys from both sides of the
relationship to a third table, called a junction or link table. In
other words, a many-to-many relationship is really just a pair of
one-to-many relationships.

How to relate table with one of many others?

I am little confused about my db design. I have orders table that may have records from one of many others. So is it OK to relate each tables with 1:1 to orders. Please look at orders domains and hostings table relations.
My orders table rows has either a domain or hosting regarding to its orders_type value.
Are you asking if the orders should have 1:1 relationship with domains and another 1:1 relationship with hostings? If you are, the answer is no. Your hosting table has an orders_id which implies means that you can have multiple hostings with the same order, i.e., orders:hosting is 1:M.
{Regarding domains, orders:domains => 1:M}