Database

From Dragon Age Toolset Wiki
Revision as of 23:58, 27 June 2009 by BryanDerksen (Talk | contribs) (imported from extranet)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

At the moment our internal documentation on the database schema used by the toolset is too out of date to be posted here; it will be added at some time in the future.

The toolset uses a named SQL instance, so you want to connect with your client using the format:

.\BWDATOOLSET

Backing up your database

Backing up a database is not as simple as just copying a file. You'll need to export the data from the database in a more portable form.

There are currently three approaches to backing up your database.

SQL Express Management Studio

Go to Microsoft and download the SQL Express Management Studio for free.

This will allow you to have a more friendly GUI interface into the toolset's database. It also means you can cause damage to the database as well, so be cautious with this tool. After registering your server you can backup your database to a file, in the same manner that the initial database has been packaged for the installer. In the future you can then restore that backup over top of the newly created database and then apply the migration scripts.

Batch file and command line

You can create a batch file with the backup command in in.

You can then run the batch files to backup your database and restore it, with you controlling the file names and such.

Builder to builder export

In the toolset you can go to the menu and select Tools->Export Database (Database Export) This will allow you to save out the entire source data into an xml file. When you reinstall you can then go to tools->Database Import and bring all the data back in. This one is a bit more work in that it will recreate everything and not put everything back the way it was. A small difference but still a difference.

Useful queries

Conversation Search

SELECT m.Name, uri.Folder, uri.ResRefName, st.Text, cl.Icon, st.StringID
FROM dbo.v_ModuleTree mt 
JOIN dbo.t_Module m ON m.ID = mt.AssociatedModuleID AND mt.ModuleID = @ModuleID
JOIN dbo.v_UserResourceInfo uri ON uri.ModuleID = mt.AssociatedModuleID 
JOIN dbo.t_ConversationLine cl ON cl.ModuleResRefVersionID = uri.ModuleResRefVersionID 
JOIN dbo.t_StringText st ON cl.TextStringID = st.StringID AND cl.ModuleResRefVersionID = st.ModuleResRefVersionID
WHERE st.Text LIKE '%' + @Search + '%'
AND ( cl.Icon = @Icon OR @Icon = -1 )
ORDER BY m.Name, uri.Folder, uri.ResRefName, cl.Icon 
OPTION ( force ORDER )

Script Search

SELECT m.Name, uri.Folder, uri.ResRefName, uri.resrefid, 
'... ' + substring( s.text, patindex('%' + @Search + '%', s.Text) -30, len(@Search)+60 ) + ' ...' as matched_on
FROM dbo.v_ModuleTree mt INNER JOIN
dbo.t_Module m ON m.ID = mt.AssociatedModuleID AND mt.ModuleID = @ModuleID INNER JOIN
dbo.v_UserResourceInfo uri ON uri.ModuleID = mt.AssociatedModuleID INNER JOIN
dbo.t_Script s ON s.ModuleResRefVersionID = uri.ModuleResRefVersionID
WHERE (s.Text LIKE '%' + @Search + '%')
ORDER BY m.Name, uri.Folder, uri.ResRefName OPTION (force ORDER)