I am trying to figure out the correct way to use .NET DataSets. Do you intend to create a DataTable for each table in your database and create relationships in a DataSet? It seems crazy to restore the entire database structure in a DataSet.
I am using a simplified example of my database. Let's say I have a table CompanyEquipment. Each piece of equipment refers to a cost center, and cost center data is stored in a table CostCenterand refers to a table CompanyEquipment. Suppose I have a stored procedure that returns CompanyEquipmentdata already connected to a table CostCenterin order to return all the information in a single query. I could use a stored procedure to populate it DataTable, but how would I save this normalized result table to a database? I do not know if this is good to do. In any case, querying a many-to-many relationship that uses association (bridge) tables will require several queries. For example, I have a table EquipmentRolethat stores various ways of using equipment, and a tableEquipmentRoleAssignmentwhere several parts can be assigned to parts of the equipment.
Alternatively, if I have DataTables that mimic the database, I would have to query each table separately using the DataAdapter.Fill () for each table to put the corresponding data in each DataTable. So I would have something like select * from CompanyEquipment where equipID = 1234that, and I would use this with the adapter to populate CompanyEquipment DataTable, and then I would have to use another request select * from CostCenter where costCenterID = <costcenterID from the companyequipment record>and populate CostCenter DataTable. With this approach, I have to hit the database twice, and I lose the ability of the DBMS to perform joins.
, , ; , , . . #.