Do both stories take place in the same universe?
Are they somewhat dependent on each other?
If so, in which order should the series be watched?
Chronologically, Railgun comes first. Then near the middle of Railgun (the Level Upper Arc), the events and timeline start to converge with Index.
For an example, in episode 17 of the Railgun anime, Komoe-sensei mentions how she likes all her students, even the ones that blow up her roof, which is probably a reference to when Index used Dragon's Breath (episode 6 of Index).
The manga gives a better frame of reference, since it gives a exact date (July 16th). So the events in Railgun begin 4 days before the Index novel (July 20th), where Touma first meets Index. Touma meets Mikoto on the eve of July 19th.
According to the TV Tropes:
The anime, however, violates this by adapting events from Volume 8 of the novels into the anime's first episode. As it stands, Chapters 18 to 39 occur around the time of Volume 3 in the novels, Chapter 40 is around volume 5, Chapters 41-42 and around volume 8 and Chapters 43-current take place around volume 9.
Adding onto кяαzєя's answer, a good resource that specifies the chronology of Index and Railgun in much more detail is the Baka-Tsuki Unified Index Calendar, which is an fan-compiled calendar of all events in the Toaru Majutsu no Index franchise.
As of January 2018, the calendar includes the following source materials, up to the specified issue (with the latest in-universe date specified in parentheses):
- (Light Novel) A Certain Magical Index: NT volume 19 (Dec. 12)
- (Manga) A Certain Magical Index: chapter 123 (~Oct. 7)
- (Manga) A Certain Scientific Railgun: chapter 100 (~Oct. 14)
- (Manga) A Certain Scientific Accelerator: chapter 42 (~Sep. 10)
- (Manga) Astral Buddy: chapter 7 (~Sep. 28)
- (Anime) A Certain Magical Index: II episode 24 (Oct. 3)
- (Anime) A Certain Scientific Railgun: S episode 24 (Sep. 2)
The calendar is frequently updated.
Railgun is a non-canon spinoff using the characters and setting of Index.
by that definition:
I guess they take place in alternate universes.
They are indepedent besides setting and characters.
Watching both seasons of Index before Railgun is in my opinion for the better.