Of Modern Databases Especially the Relational One
Total Page:16
File Type:pdf, Size:1020Kb
Of Modern Databases Especially the Relational One overview in general November 2012 by Sigrún Gunnarsdóttir Database Administrator ÍSOR - Iceland GeoSurvey Table of contents What is a database? - Spreadsheets or ....? ........................................................................................ 3 Types of databases................................................................................................................................ 4 Storing and securing a Database and accessing information using one ....................................... 4 Database tables and how to manage them ....................................................................................... 5 Database design .................................................................................................................................... 5 Database normalization ....................................................................................................................... 6 What is DBMS? ..................................................................................................................................... 7 The choice of DBMS - Oracle, DB2, Informix, PostgresPlus, MySQL, MS-SQL Server ...??? ..... 8 Going over to a relational database ................................................................................................... 9 Role of DBA ......................................................................................................................................... 11 Some tools for input and output of data ......................................................................................... 11 References ............................................................................................................................................ 15 2012_Of_modern_databases_and_the_relational_one.docx Sigrún Gunnarsdóttir Updated: 16.th November 2012 Page 2 of 15 What is a database? - Spreadsheets or ....? With some Google search (like e.g. “what is a database” or “define:database”) one can find all about that, both the older and more simplified definitions: An organized body of related information A database defines a structure for storing information upto the ones recently used definitions which include computer systems: A database is a structured collection of records or data that is stored in a computer system – (in system files of some DBMS – Database Management System – or just in raw unix textfiles) Modern databases are designed to offer an organized mechanism for storing, managing and retrieving information. They do so through the use of tables. If you’re already familiar with spreadsheets like Microsoft Excel, you’re probably accustomed to storing data in tabular form. Just like Excel tables, database tables consist of columns and rows. If a database is so much like a spreadsheet, why can’t I just use a spreadsheet? Databases are actually much more powerful than spreadsheets .... Here are just a few of the actions that you can perform on a database that would be difficult if not impossible to perform on a spreadsheet: • Retrieve all records that match certain criteria • Update records in bulk • Cross-reference records in different tables • Perform complex aggregate calculations The database used to be an extremely technical term used only by large institutions or companies, however with the rise of computer systems and information technology throughout our culture, the database has so to say become a household term. In order for a database to be truly functional, it must: • store large amounts of records well • be accessed easily • new information and changes should also be fairly easy to input Besides these features, all databases that are created should be built with high data integrity and the ability to recover data if hardware fails. 2012_Of_modern_databases_and_the_relational_one.docx Sigrún Gunnarsdóttir Updated: 16.th November 2012 Page 3 of 15 Types of databases There are several common types of databases and each database type has its own data model (how the data is structured). They include: • Flat Model • Hierarchical Model • Relational Model • Network Model More about the Flat Model and Relational Model here later on, in Going over to a relational database. The Hierarchical Model organizes data into a tree-like structure that allows data tables being represented using parent/child relationships so that each parent can have many children, but each child just one parent. The Network Model uses a flexible way representing data tables and is not restricted to being hierarchical or lattice. The relational model is the most popular type of database and an extremely powerful tool, not only to store information, but to access it as well. Relational databases are organized as tables. A table can have many records and each record can have many fields. Tables are sometimes called a relation. It should be noted that every record (group of fields) in a relational database table has its own primary key: one unique field or some few fields combined that makes it easy to identify a record. Relational databases use a program interface called SQL or Structured Query Language. SQL is currently used on practically all relational databases. Storing and securing a Database and accessing information using one While storing data is a great feature of databases, for many database users the most important feature is quick and simple retrieval of information. Queries are requests to pull specific types of information. No matter what kind of information you store on your database, queries can be created using SQL to help answer both simple and important questions. Databases can be very small (less than 1 MB) or extremely large and complicated (terabytes as in many government databases), however all databases are usually stored and located on hard disk or other types of storage devices and are accessed via computer. Large databases may require separate servers and locations, however many small databases can fit easily as files located on your computer's hard drive. Obviously, many databases store confidential and important information that should not be easily accessed by just anyone. Many databases thus require passwords and other security features in order to access the information. While some databases can be accessed via the internet through a network, other databases are closed systems and can only be accessed on site. 2012_Of_modern_databases_and_the_relational_one.docx Sigrún Gunnarsdóttir Updated: 16.th November 2012 Page 4 of 15 Database tables and how to manage them • Tables are the basic unit of storage in a database. Tables are usually defined by a name, a set of columns, and other optional parameters. For each column, a column name, data type and width, precision, or scale must be specified. • Just like Excel tables, database tables consist of columns and rows. Each column contains a different type of attribute and each row corresponds to a single record. • Using SQL statements, data can be added and removed from the table by rows. Each row represents one data record. Data can also be modified through SQL by removing columns or changing some column value for a record. • Some various software tools can be used to interact with the database, for example SQLPLUS, MS Access, dbVisualizer, Navicat and many, many more, in order to view, insert or update data. More about that later on. Database design Before data entering database tables there are some stages of design. A good design of a database structure in the beginning can prevent levels of complexity at later stages. The main design of a database can take place even before a database management system has been chosen. The main building blocks of a database consist of so called entities, attributes and relationships between the entities. An entity may be defined as a thing which is capable of existing independently and which can be uniquely identified. In other words an entity is anything that might deserve its own table in the database concerned. An entity must have a minimal set of uniquely identifying attributes, which is called the entity's primary key. The relationships between entities can be optional or compulsory. When designing a database you should start with identifying it's entities. This is mostly a matter of talking to some people who will use the database and figuring out what data the system will be working with. An internet shop, as an example, sells products which are ordered by customers. In this one sentence three obvious entities of a database for this shop have already been mentioned, product, order and customer. To decide on entities, what is to be an entity in a database or an attribute or relationship isn't always straightforward though. Sometimes in complex data modelling we can come up with many entities that won't translate directly to tables. A lot of information regarding design of databases can be found on the internet. In software engineering, entity-relationship modeling is a method of database modeling, used to produce a data model of a system, often a relational database, and it‘s requirements in a top-down fashion. Diagrams created by this process are called entity-relationship diagrams, ER diagrams, or ERDs. 2012_Of_modern_databases_and_the_relational_one.docx Sigrún Gunnarsdóttir Updated: 16.th November 2012 Page 5 of 15 Database normalization In designing relational databases normalization is used, that is a data-structuring model which ensures data consistency and aviods data duplication,