title: Why a can't connect my tables in MySQL?
body: <p>shippings table structure
  <a href="https://i.stack.imgur.com/bVa9H.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bVa9H.png" alt="shippings table structure"></a>
  I want to connect in to another table like this(I got "1215 error"):</p>
  
  <pre><code>CREATE TABLE goods_and_shippings (
  good_id INT NOT NULL,
  s_date DATE NOT NULL,
  shipping_id INT NOT NULL,
  PRIMARY KEY (good_id),
  FOREIGN KEY (s_date) REFERENCES shippings(s_date)
  </code></pre>
  
  <p>) </p>
  
  <p>Connected columns have same data types as you can see (both DATE and NOT NULL) and all tables use InnoDB engine. But I have this snippet and it works:</p>
  
  <pre><code>CREATE TABLE goods_and_shippings (
  good_id INT NOT NULL,
  s_date DATE NOT NULL,
  shipping_id INT NOT NULL,
  PRIMARY KEY (good_id),
  FOREIGN KEY (shipping_id) REFERENCES shippings(shipping_id)
  </code></pre>
  
  <p>) </p>
  
  <p>All tables are empty for now. Here is query for creating shippings:</p>
  
  <pre><code>CREATE TABLE shippings (
  shipping_id INT NOT NULL,
  s_date DATE NOT NULL,
  driver_id INT NOT NULL,
  start_place VARCHAR(50) NOT NULL,
  end_place VARCHAR(50) NOT NULL,
  car_id INT NOT NULL,
  price DECIMAL(5,2) NOT NULL,
  PRIMARY KEY (shipping_id, s_date)
  </code></pre>
  
  <p>) </p>
  
  <p>Here alters I've used after:</p>
  
  <pre><code>ALTER TABLE shippings ADD CONSTRAINT fk_car_id FOREIGN KEY (car_id) REFERENCES cars(car_id);
  ALTER TABLE shippings ADD CONSTRAINT fk_driver_id FOREIGN KEY (driver_id) REFERENCES drivers(driver_id);
  </code></pre>
  
  <p>What's wrong in my queries? How to fix this and connect goods_and_shippings.s_date and shippings.s_date?</p>