Sei sulla pagina 1di 9

WHAT IS A DATABASE?

Hello and welcome to this eight part video lesson series, titled SQL Server 2005 Express Editions for Beginners. My name is Bob Tabor and I am with LearnVisualStudio.NET. During the course of the next eight lessons, we will start with the absolute basics and progress to the point where you can build database driven websites and applications on your own. While this series requires no previous experience with databases, you probably should have some experience with a programming language like Visual Basic or C#, and also most examples utilize Visual Web 2005 Express Edition to create ASP.NET 2.0 websites. So, if you have not so done already, please take the time to download and watch those videos, also available on Microsofts website. Now, I want to start off with the basics, so, I am going to begin with a quick example. Whether you realize it or not, almost every web page of any significance on the internet today is database-driven. Now, what do I mean by database-driven? I simply mean that many websites retrieve data from a database, and merge it with an HTML template to produce an HTML page that is consumable by your web browser, or the data that is collected from web pages forms are saved to a database. For example, I have created a little fictitious example that we are going to go through later in this video, and the other videos in this series that demonstrate how an ASP.NET web page interacts with the SQL Server 2005 Express Edition database. So, as you will be able to see here, let me take a fictitious e-mail address, and then click my submit button, and you can see that I get a page that says Thank you! You will be receiving our next newsletter shortly. Now, what happened between the point where we clicked the submit button and the point where we got this confirmation page? Well, what is happening behind the scenes, is that data is being sent across the internet, and then the web server is collecting the data, and saving it into a data source, in this case, a SQL Server 2005 Express Edition database. [Start: 00:00:00 End 00:02:09] Now, in this particular example, we are inserting records into the database. We can also show how by using Visual Web Developer 2005 Express Edition, we are able to quickly create a little administration page that allows us to retrieve data from a web page, and allows us to interact with the database in some meaningful way. So, in this particular case, you can see that we are able to change the e-mail address, we can change the date and the time that was entered into the

database, and even the IP address that we secretly collected behind the scenes in order to identify that this person came a particular address to try to prevent some fraud. We can also opt this user out by selecting this little check box, and including update. We can cancel that operation. We can even delete this record by clicking on delete link. But, could you believe that it only took me less than two minutes to create this administration application using the tools available in Visual Web Developer 2005 Express Edition. Lets take a few moments to briefly talk about what we are going to cover in the next eight lessons, and then move on and start discovering what databases are for the remainder of this lesson. So, in this first video, we are going to talk conceptionally what a database is and why you should prefer to use it rather than other options like text files, spread sheets and so on when you build your applications. In lessons 2 and 3, we are going to talk about the major database objects that are used within a relational database management system, and then the lesson 4 where we are going to talk about how to create tables in a relational sort of way. We will talk about relational database theory, and how to take a rather flat database structure that you might be used to if you are already creating Excel spread sheets and so on, and how to translate them into a more relational style of database creation. [Start: 00:02:09 End 00:04:03] In lessons 5 and 6, we are going to thoroughly explore the structured query language or SQL as it is known, sometimes called sequel, and we are going to use it to retrieve data from our database. We will learn how to sort that data, how to group it and aggregate it as well as how to insert data into our database, how to update it, how to delete it and so on using nothing more than this special programming language called SQL or Structured Query Language. In lesson 7, we are going to talk about security and network connectivity. There are some unique features of the Express Edition of Sequel Server 2005. We are going to tell you how that makes writing secure applications easier using the Express Edition tools. We will also demonstrate how to open up your database so that your application can be distributed across many client computers, each one accessing the same data in your database.

So, as we begin, let us start talking about conceptionally what a database really is. There is nothing magical about a database, it is simply just one or more files that work together to store data in a very structured sort of way. They are optimized so that we need to retrieve data out of the database that it can retrieve quickly and efficiently. But also, the organization of those files helps keep the data accurate. We will talk more about this concept of data integrity throughout all the lessons. Now, some databases are simply files, and then other databases require that there be some server software that manages the connection to those files to regulate the users that are trying to access those files. The purpose of that software is not only to make it accessible to multiple applications in users concurrently, but also to allow for the safe management and maintenance of that data and that tends to be one of the biggest focuses of working with databases. How do we manage it? How do we maintain it so that it is accurate and that we maintain data integrity? [Start: 00:04:03 End 00:06:18] SQL Server 2005 Express Edition is a free application that allows you to create and manage databases for your applications. We will be a little bit more specific because that are very high level, that is what it does but, there are actually many different pieces to SQL Server 2005 Express Edition that are used in various scenarios. Some applications work behind the scenes to ensure that multiple users can access the data at the same time, while, other applications are more of a management nature that allow you to add tables, columns and things of that nature, and allow you to select data from the database, and we will talk about these things in the upcoming lessons. Just keep in mind that SQL Server 2005 Express Edition is a complete tool set, not just the files themselves that store the data, but then also the management tools and the server tools that sit on top of the file structure in order to help you use and manage your database. Now, if this is your first exposure to databases, relational databases specifically, you might be asking yourself why all this complexity. Why could not we just store data in flat text files? Or even potentially store them like you have been doing in your small organization using spreadsheets or whatever the case might be. Certainly there is a layer of complexity thats added to creating applications by using a database SQL server. However, it actually makes

things a lot easier when you really sit down and think about some of the weaknesses of using simple flat text files or spreadsheets to manage your data. [Start: 00:06:18 End 00:08:01] For example, if you were to have a spreadsheet or even a text file of data that contain, for example, customer data, every time the customer purchases something from your company, we have a complete record of their name, address, city, state, zip code, along with the purchases that they made, and if you were to think about storing each record of an individuals purchases on a separate row of a spreadsheet, you will see that first of all, there is a lot of redundant information, the address information, the city, state information, for example, might be redundant across multiple rows. Now, that could be a problem, especially in light of the fact that if they purchase three months from now, some of their information may change. They may have moved. They may no longer work for the company that they once did. Over time, some of the data that you collected about this individual might become outdated. You might have a hard time, figuring out which of these particulars rows is the most recent row that accurately describes this particular individual in my spreadsheet. Not only that, but with all that redundant data being saved each time in a different row, it does increase the file size. Now, for a simple application, that may not be a problem, but when you saving tens of thousands of rows of data over the course of a number of years, certainly there needs to be a better way, a more efficient way to manage that data. Although, for example, Microsoft Excel is very adept in allowing you to filter and search through the data in your spreadsheet, some more complex searches might not be enabled due to the way that the data is structured. [Start: 00:08:01 End 00:09:55] So, once we review the structured query language in lessons 5 and 6, I think your eyes will be open to all the possibilities, all the flexibility that was not available to you when you were using Excel spreadsheets to manage your data. And then other functions like protecting data from malicious and unauthorized use. Is there any way to do that with a text file? Absolutely not. With a spreadsheet? Not very easily. How about protecting the data from becoming corrupt? Well, there again, if the file becomes corrupt, you are really out of luck. As you can probably tell as Im leading you into this discussion, a relational database management system, which you often see shown to you, RDBMS, will take care of many of these issues for you, and SQL

Server 2005 Express Edition is certainly no exception of that. It takes care of a lot of the heavy lifting of managing your data. So, yes, there is a little bit of an overhead compared to the simplicity of text files and spreadsheets, however, the flexibility and the security of using an RDBMS system will really outweigh the disadvantages of having to learn a whole new syntax, a whole new of thinking and so on. So, up to now, I have used the term relational several times in reference to databases. Well, what does that mean? What are relational databases? Well, relational is a type of database. Not all databases are relational, but, it is probably the most popular type of database that you use commercially use today. Relational databases were conceived of back in the 1970s by an IBM researcher whose name was Codd, he was the father of relational database theory. They were popularized in the 1980s as some of these theories began to find their way in the commercial tools. But Codd wanted to solve two basic problems that existed with databases up to that point in time where all the data was handled by these huge mainframe computers, and the storage capacity was limited and very expensive. [Start: 00:09:55 End 00:12:00] So, first of all, he wanted to reduce the footprints of the data, thereby reducing the amount of space on those big reel-to-reel tapes that each database record required, and hopefully, would reduce how expensive data was to store. He also wanted to enforce data integrity. Now, data integrity takes several forms, but, we are basically referring to the accuracy and the correctness of the data that we are storing. To accomplish this, Codd suggested that if you break up one long row of data fields into several smaller records, each record being saved into a table that describes its specific subset of the data that is collected, you can improve the integrity of the data. First off, he suggested that you had to define what type of data you wanted to store, and that would prevent scenarios where you had like string or character data in a field that should only be storing numeric values. So, by enforcing strong data types, it makes the data instantly more correct, and therefore, helps maintain the integrity of the data. But, then also by storing a data entity in just one place, in one record, you can eliminate the possibility of having multiple versions of the same data in your database, therefore, improving the integrity of the data by reducing the possibility that one of the versions of the data is incorrect. Also, another benefit of breaking up the data into smaller related tables of data is that you can rely on the sop that manages the interaction with the data protected from deletions when deleting a record would mean that it broke an important relationship that it had with other data that was related to. So,

you ensure data integrity by disallowing any potentially harmful deletes of data in the database. And probably, most importantly, was that by splitting up the data into smaller chunks, you could retrieve data much more quickly than in the past. So, SQL Server 2005 Express Edition is a relational database, meaning that you get the advantages of relational databases and more, leading to safer, cleaner data that is stored by your application. [Start: 00:12:00 End 00:14:16] Now, if some of that did not make sense, do not worry. In the next seven lessons, we are going to cover enough tangible examples that some of this theory will become very obvious to you. While there are some inherent advantages to working with relational data, there are also certain services that weve come to expect from the software that sits on top of the actual file structure that holds the data, and we commonly refer to that as the relational database management system. So, that software will support our efforts in a number of ways. For example, allowing multi-user access and also controlling access and permissions on a user-by-user basis. So, the topic of security authentication and authorization to perform some tasks is managed by an RDBMS. Basic administrative tasks, like backing up and restoring the data, making sure that it will be there whenever you actually need it. Also, the ability to replicate the data across a number of servers so that if one server goes down, that there can be some redundancy available or more importantly that you can allow multiple applications to have their own copy of the data and it all stays updated. Also, some basic ad hoc reporting capabilities, the ability to write Transact SQL, the variant of SQL that SQL server allows to use, and be able to retrieve data without having to create special applications just to call certain piece of information down. So, the ability to write SQL statements and retrieve data on an ad hoc basis is another important service of an RDBMS, and finally, just making the data available, making sure that it is up and running in that it is serving the data and doling it out as requested. [Start: 00:14:16 End 00:16:19]

So, let us move on to more practical topic, and that is where do databases fit into the overall architecture of your application. Now, when you are first getting started, you are probably going to create fairly simple applications that will be deployed to a single machine. SQL Server 2005 Express Edition certainly supports this. You can deploy the actual database files to a folder of your ASP.NET 2.0 application. But, what is actually going on behind the scenes to

facilitate the access of that data. For example, at the very top here, you can see where a network web page is requested. So, somebody types in http://www.something.com into your particular web server, and if your web server is running Windows 2000, Windows 2003 or something along those lines, then internet information service is going to retrieve that request, and determine what to do with it. If the request has a certain file extension like .aspx, then it knows that it is going to depend on the ASP.NET runtime engine to interpret and handle this request. Upon receiving this, the ASP.NET runtime engine will basically load up your web page and will execute the commands that are stored within the assembly that is generated whenever the web page is run for the first time. That assembly will rely on classes that are within the framework class library, the FCL, which in turn go to a special subset of classes called ADO.NET, which we will talk about, in future lessons, and ADO.NET is responsible for communicating with your database whether to save information in, retrieve information out to later update, or whatever the case might be. For example, information should be returned back to your application, then that will be integrated in through ASP.NET replacing the programmatic fields of information with HTML, returning it back through internet information services and back out to the original requester of the information. [Start: 00:16:19 End 00:18:47] Now, understand that I am really oversimplifying this just so you can understand the flow of information that comes in to build a web page request, and it gets all the way down to the point where it is collecting data from SQL server, and then retrieving that, integrating it back into the web page, and splitting it out. There is a lot more to it than that, but from an overall perspective, I think that is a pretty high-level overview of what is going on behind the scenes. Now, honestly, SQL Server 2005 Express Edition was created with a single server scenario where you are not expecting hundreds of thousand or millions of requests per day. If you are expecting to handle that kind of load, you may need to turn to a more enterprise class, end tier multiple servers scenario where you have a number of computers that are handling the initial load, the initial request from the internet, and these servers know how to serve up the HTML that is generated by your application. You may have another bank of computers that their only job is to just to serve up data to that top tier, that interface tier application, and these know how to enforce business rules that are unique to your particular company. Then finally, you may have one or more computers that are responsible for serving out data to that middle tier, and these might run a professional or enterprise version of SQL Server, and do so on very expensive

multiprocessor computers complete with redundant drives, clustered to provide fail over services and so on. [Start: 00:18:47 End 00:20:47] Now, while some of the concepts that we will talk about in the next few lessons will help you prepare you for that environment, really, that is a whole other set of concerns in services in tools that will be made available to you from some of the higher end version of SQL Sever, but, you have got to start somewhere. As you become more proficient with SQL Server 2005 Express Edition, you will find that transitioning into a better understanding of the more professional enterprise versions of SQL Server 2005 Express Edition will become actually very easy for you. So, we just looked at where SQL Server will fit into an implementation perspective. But, where does SQL Server 2005 Express Edition fit in from a tools perspective? Well, first of all, as you have probably noted, if you have already worked with Visual Basic, C# or ASP.NET tools, you found that SQL Server 2005 Express Edition is baked right into the tool set. You had basic creation and management capabilities directly from that Visual Studio IDE that is common across all the tools, and if you have worked with those tools for very longer, or watched the other videos that we created at LearnVisualStudio.NET, you have noticed that there is a lot of built-in functionality between, for example, ASP.NET 2.0 and SQL Server 2005 Express Edition by just merely dragging and dropping some of the representations of tables from the visual tools onto your designer surface that it creates a lot of code, a lot of links behind the scenes for you, and enables a lot of functionality very quickly. That visual drag and drop paradigm allows for some very easy interaction between your applications the underlying data store in this case, SQL Server 2005. [Start: 00:20:47 End 00:22:40]

But, then also as we are going to look at several lessons in this series, there is an additional tool that is available for download, and that is SQL Server Management Studio Express, and it allows for some more advanced management and administrative functionality, and we will spend lesson number seven talking about the features that are included in SQL Server Management Studio Express, including where you can download it, how to install it and so forth.

Now, when you are building your applications using, for example, Visual Web Developer 2005 Express Edition, and you are doing while we talked about just a moment ago where were dragging and dropping tables, for example, from the database view onto your designer surface, there are actually some things going on behind the scenes in order to enable the functionality, the handshake, between your application and the database, and we noted, as we looked at the implementation perspective of that single server scenario, we talked about subset of framework class library called ADO.NET that really facilitates the ability for your application to talk to the underlying data store. So, think of that subset ADO.NET as the bridge between your application and the underlying database. ADO.NET handles a lot of the heavy lifting for you, for example, the initial handshake with the database, making sure that it can find it in the physical location on your hard drive that it would expect to find it in, and making sure that you can open up, and that you have the correct permissions to interact with that database. And then taking care of some of the execution of commands like inserts, updates, deletes and so forth, and then also the execution of queries to retrieve and filter through data and so forth, and then it also provides some additional utility in so much that it allows you to interact with code objects in Visual Basic or C# that closely mirror the table structure, the underlying data objects; how your are data is stored in the database. In fact, in some cases, you do even have to think about the data being stored as fields of information or even as a database, but they are strongly typed. You are able to interact with these entities, these ideas, by their real names, allowing you to think about things in a much more object-oriented sort of way. [Start: 00:22:40 End 00:25:19] And that brings us to the end of first lesson. Please understand if there were things here that did not make sense that is fine. We are going to cover all of the details about what a table is, what a column is, how do we create tables and columns within our databases, how do we create databases, how do we query data from those tables, and do we insert data into them using Visual tools and using the special programming language called SQL. All those topics, we are going to cover here in the next few lessons so, stay tuned. If you enjoy this video and the rest of this video series, please visit http://www.LearnVisualStudio.NET for over 500 screen cam videos just like this one on all topics related to .net including C#, Visual Basic, ASP.NET and more. Thank you. [Start: 00:25:19 End 00:26:17]

Potrebbero piacerti anche