与 + [noun] + 相比,[sentence]
[A] + 与 + [B] + 不同 / 一样 / 相同 / 差不多
[A] + 与 + [B] + 有关 / 没有关系
[subject] + 与 + [person] + [verb phrase]
与 means "with". It does the job of 跟 and 和 in writing: news reports, notices, essays, headings. The 与 phrase goes before the verb or adjective, never after it.
In conversation the same sentences take 跟, and 与 sounds stiff there.
与 + B + 相比 opens a sentence and sets up what A is being measured against. The rest of the sentence states the difference, usually with 更 or a change; it doesn't repeat 比.
与 + B + 不同 / 一样 / 差不多 says how A stands next to B. 与 + B + 有关 says A is connected to B, and 与 + B + 没有关系 says it isn't.
English puts "with someone" and "from something" after the verb. Here the 与 phrase sits before it.
Between two nouns, 与 also means "and", as in titles: 老师与学生.