Both were in some way derived, but the lineage is closer for the Democrats.
The Democratic-Republicans split into factions during the 1820s, resulting in the formation of the Jacksonian Democrats and the National Republicans, which became the Whigs. The National Republicans/Whigs were generally closer to the policies of the defunct Federalist party than to those of the Jeffersonian Republicans.
I think of the lineage as basically this:
Anti-Federalists --> Jefferson Republicans --> (major faction) Democratic-Republicans --> Jackson Democrats --> Democratic Party
Federalists --> ( faction within Democratic-Republican Party) --> National Republicans --> Whigs --> (+anti-slavery Democrats, minor factions) Republican Party
Don't forget that southern Whigs became Democrats after the Whig Party's collapse.
Not quite. The Southern Whigs along with some Northern Whigs, first became Know-Nothings under the campaign name of American Party and they also provided most of the support of the short-lived Constitutional Union Party of 1860.