Persistent data storage

persistent storage definition and persistent storage in recovery
Dr.MasonHanks Profile Pic
Dr.MasonHanks,Germany,Teacher
Published Date:23-07-2017
Your Website URL(Optional)
Comment
Object Oriented Software Development 10. Persistent Storage www.ThesisScientist.comPersistent storage  Objects in memory are destroyed when a program is shut down or if it terminates unexpectedly  Information is lost and is not „remembered‟ the next time the program runs  It is often necessary for information to be persistent  Stored permanently even after program terminates  Can be retrieved by the program when needed www.ThesisScientist.comTypes of persistent storage  Files  Text files  XML files  Binary files  Databases  Usually relational database although there are others, e.g. object database, “NoSQL” database  Database can be local (on same machine as program) or on a remote server accessed across a network www.ThesisScientist.comWorking with files and folders in C  System.IO namespace provides classes which can be used for working with files and folders (directories)  FileInfo  Provides properties and instance methods for the creation, copying, deletion, moving, and opening of files  DirectoryInfo  Provides instance methods for creating, moving, and listing directories and subdirectories www.ThesisScientist.comExample code  DirectoriesAndFilesDemo  Program.cs www.ThesisScientist.comListing directory contents symbol before string allows \ in string – otherwise \ is interpreted as part of an escape sequence (e.g. \t means a TAB character) www.ThesisScientist.comCopying files www.ThesisScientist.comReading from and writing to files  FileStream  Allows programs to access files and read and write binary data  StreamReader  Allow programs to read text from a FileStream  StreamWriter  Allows programs to write text to a FileStream  Reader/Writer “wrap around” a FileStream (or other type of stream, e.g. NetworkStream) www.ThesisScientist.comOpening a FileStream  FileMode  How the file is opened  Create, CreateNew, Open, OpenOrCreate, Append  FileAccess  How the file is accessed  Read, Write, ReadWrite  These are enums (remember them?) www.ThesisScientist.comExample code  StorageDemo  FileTimeSheet.cs www.ThesisScientist.comFileTimeSheet  Complete code for FileTimeSheet class we saw in Employees example project using block means we don‟t have to call Close method when finished with StreamWriter storing employeeId rather than name as it uniquely identifies an employee www.ThesisScientist.comWorking with databases in C  ADO.NET  Set of .NET classes for accessing relational databases  Program sends SQL queries to database and receives results  Entity Framework  Object-oriented approach to working with data  Queries are written in C using LINQ  SQL generated “behind the scenes”  ADO.NET is the underlying technology www.ThesisScientist.comADO.NET  Classes for working directly with a database:  Connecting to a database  Sending a query to a database  Reading the results of a query  Classes for working with data in memory while disconnected from the database  DataSet, DataTable, etc  Can re-connect and update database when ready www.ThesisScientist.comADO.NET connected classes  Connection  Represents a connection to a database  Location of the database (local file, local server, network server) defined in connection string  Command  Allows a command (query) to be sent to database using a Connection  Command can be defined as SQL string  DataReader  Allows program to step through query results www.ThesisScientist.comConnected and disconnected database access  We will focus on connected classes here  Similar approach to other languages, e.g. JDBC for database access in Java  DataSets, etc. are very powerful and useful, but are specific to .NET  Suit a data-centric rather than object-oriented approach to designing applications www.ThesisScientist.comWorking with different databases  There are many different relational database systems  Use same programming model (Connection, Command, DataReader) for any database  Actual classes used depend on the specific database www.ThesisScientist.comWorking with different databases  SqlConnection (etc)  Microsoft SQL Server databases  OleDbConnection  A range of database including Access, Oracle, MySql  OracleConnection  Oracle databases  SqlCeConnection  Microsoft SQL Server Compact Edition databases www.ThesisScientist.comSQL Server  Microsoft‟s enterprise database  More scalable and robust than Access  Designed to be run on a server, usually accessed over a network  Compact Edition  A lightweight version of SQL Server intended to be used on mobile devices, etc  Database is a local file (.SDF file)  Also convenient for prototyping and example code www.ThesisScientist.comExample code  QueryDemo  Program.cs www.ThesisScientist.comThe database – payroll.SDF Employees Departments www.ThesisScientist.com

Advise: Why You Wasting Money in Costly SEO Tools, Use World's Best Free SEO Tool Ubersuggest.