---
title: "Automatic Data-Relations"
url: "https://osherove.com/blog/2003/9/4/automatic-data-relations.md"
canonical: "https://osherove.com/blog/2003/9/4/automatic-data-relations.html"
published: "2003-09-04T13:01:00"
updated: "2003-09-04T13:01:00"
tags: [".Net Original"]
author: "Roy Osherove"
description: "Greg asks about data relation support in Yukon . Meanwhile, in the present, there are several ways to avoid building those relations manually in code: Return hierachical data from your SQL server procedures (with the…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# Automatic Data-Relations

By Roy Osherove September 4, 2003 In [.Net Original](https://osherove.com/blog/category/net-original)

**Historical article** · Originally published September 4, 2003; technical details may be outdated.

[Greg asks about data relation support in Yukon](http://weblogs.asp.net/grobinson/posts/26340.aspx). Meanwhile, in the present, there are several ways to avoid building those relations manually in code:

- Return hierachical data from your SQL server procedures (with the FOR XML keywords). When you use ExecuteXMLReader() against this data, you can make your dataset read the XML from the reader. Automagically, all the relevant data relations that appear in the returned hierarchical XML will be created within the dataset. You get the added benefit of retrieving multiple tables in a single call to SQL server.

- Another way is for when you can't return XML from your queries. You can use my [SchemaHelper](http://weblogs.asp.net/rosherove/story/9661.aspx) class to automacially build any data relations between tables that are present in your dataset. The class queries the database for its underlying schema (using OleDbConnection.GetOleDbSchema()) . Right now it needs an OleDbConnection, but there is also a way to retrieve the schema data from a SqlConnection , which I hope to add to the class soon.

## More in .Net Original

[All posts in .Net Original](https://osherove.com/blog/category/net-original)

- Sep 10, 2003

    ### [So, you have to live with 1.0?](https://osherove.com/blog/2003/9/10/so-you-have-to-live-with-10.html)

- Sep 8, 2003

    ### [Issues and solutions with Process and Request Identity in ASP.NET](https://osherove.com/blog/2003/9/8/issues-and-solutions-with-process-and-request-identity-in-as.html)

- Sep 4, 2003

    ### [Debugging shortcuts - Run to cursor, Find next statement](https://osherove.com/blog/2003/9/4/debugging-shortcuts-run-to-cursor-find-next-statement.html)

- Sep 4, 2003

    ### [Books to buy](https://osherove.com/blog/2003/9/4/books-to-buy.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
