how to construct a Schema

  • Thread starter Thread starter RayAll
  • Start date Start date
R

RayAll

Hi,

I have a table which has 3 forign keys to three other tables.I's to make an
schema out of this table which contains all the constrainsts and all its
relations and also I'l like to have the records from the look-up tables to
be included into that schema.The reason I like the data is that .I want to
pump data into a dataset ,but I want to make sure that no viloation
happens,I mean I want to make sure that when I pump data into the dataset
for the field country code for example ,the related table contains that code
for sure.

Is there somebody who can help me.

Thanks
 
Ray,

You can make a schema in 3 ways --

a) Programatically on a dataset.
b) By manually writing up an XSD
c) By creating an XSD via the Visual Studio strongly typed dataset designer.

Also you can do fillschema, but that defeats your purpose here I think?

That will take care of "Constraints and Relations".

Regards the "Records from lookup tables to be included in that schema" --
Well technically that is data, and data cannot be a part of Schema, so you
cannot specify that as any of the above HOWEVER, you can easily acheieve
that by doing a "Fill" operation with the necessary
ForeignKeyConstraints/DataRelations enforced. Given that you have such a
constraint defined, the child table may or may not contain the childrows
(yet), and during fill they will be validated against this constraint -
which is what you need. :)

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Hi,

What you could do is to create relations between you DataTables inside of
the DataSet. It will enforce checking of the constraints to allow only
valid. Check DataRelation class and ForeignKeyConstraint class for it.
 
Can I define an specific format for a column in Schema?
for instance for one column I'd like the data to like this format "dd/dd/dd"
..

Thanks
 
Ok ,I defined the schema by using Visual Studio Designer
Now how can I make a Strongly-Typed Dataset agianst it?
Should I use the command tools or I can do it directly from VS2003?

Thanks for your help.
 
I don't think so .. though I don't claim to be an XSD expert. But you can
restrict to a date data type.

But you can acheive the same result by hooking onto the RowChanging event on
a Table, and latching onto the new row, appropriate column and writing some
C# goo around formatting.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Okay there are 2 ways to make a strongly typed dataset. This is described in
Chapter 5 in my first book and Chapter 6 in my second.

Once you have the XSD authored -

1. The manual way. Run the xsd.exe tool to generate the strongly typed
dataset code.
2. The visual studio way. Drag drop the XSD to your project (yes it's that
simple). OR author the XSD in Vstudio by right click --> Add new dataset,
and author the schema right there using point and click.

Just one important point of note - not every xsd qualifies to be a dataset.
I believe in .NET 2.0 there is a InferSchema class that has an IsDataset
property on it. (Or was it also available on the
System.Xml.Schemas.XmlSchema class? My memory is a bit hazy there, but
that's a way of checking IF a schema qualifies to be a dataset or not.

HTH :)
 
Back
Top