Method and apparatus for associating metadata with data