Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Microsoft Access wikipedia , lookup
Business intelligence wikipedia , lookup
Data vault modeling wikipedia , lookup
Entity–attribute–value model wikipedia , lookup
Concurrency control wikipedia , lookup
Versant Object Database wikipedia , lookup
Clusterpoint wikipedia , lookup
Resear ch Relational Databases: A Beginners’ Guide What is a relational database? A relational database is a means of storing, manipulating, and analysing structured data. Databases store data in tables: A table consists of a series of records: o A record is a collection of information about a given entity. o The entity might be a person, an object, a text, an image, a transaction, an event, or almost anything else you care to name. o Each row of a database table contains one record. The table columns are known as fields: o Each field contains one piece of information about the entity being described. A simple database table might look like this: ID Title Author Date Publisher 1 Introduction to Ethics Smith, Beth 1988 Blackwell 2 A History of London Brown, Adam 2001 OUP 3 Political Theory: A Primer Jones, Jane 2005 OUP This table contains three records, and has five fields. A flat file database has just a single table. In some cases, this may be all that’s needed. A relational database, however, can have multiple tables, with – as the name suggests – relationships between them. This allows you to record information about multiple types of entity, and to show how these are connected to each other. For example, consider the table above. Each record gives several pieces of information about each book. If you want to record more information about the books – number of pages, perhaps, or price – you could do this by adding more fields. However, suppose that you also wanted to record further details about the author. You could do this by adding further fields, but if some authors have written multiple books, this would result in a lot of repeated information. A more elegant solution is to create a separate table with one record for each author, and then to create links between the two tables. Each table in a relational database has a field which is designated the primary key. The entries in this field serve as unique identifiers for the records, enabling records with similar contents to be distinguished from each other. Imagine, for example, a library catalogue which includes multiple copies of the same book: their records might look much the same, but it would still be possible to tell which copy was being referred to by looking at the primary key field. The primary key is also used to identify which record is being referred to when links are created between database tables. Resear ch In theory, any field can serve as the primary key, but in practice it is often easiest to add an ID number to each record, and use this. This avoids the risk of accidental duplication. Why use a relational database? When working with structured data, there are several reasons to use a relational database: Some datasets are too complex to be adequately represented using a flat file Database management systems include tools which can help make entering data easier and more accurate Databases allow you to sort, filter, and manipulate your data in sophisticated ways Databases allow you to present your data (or a subset of it) in a wide range of ways Database management systems (DBMS) are software packages for creating and storing relational databases. Common desktop database management systems include Microsoft Access, OpenOffice.org Base, and FileMaker Pro. Database management systems typically offer a number of features designed to reduce errors and improve consistency. For example, it's possible to restrict the type of information that can be entered in a given field – to specify that it has to be a date in a particular range, for example. This is particularly helpful if multiple people are going to be using the database. When there are a limited number of options, you can create a drop-down list from which the user can select the appropriate option: this both saves time and reduces the risk of typos which might make it harder to locate information when you search for it later. Designing a database If you’re creating a database from scratch, you need to give careful thought to the structure: the tables you’ll need, the fields each table should have, and the links you need to create between them. Key questions to ask include: How many types of entity am I dealing with? What do I want to record about each of them? What do I want to be able to do with the database once it’s up and running? If you’re new to databases, it’s well worth investing some time in learning the basic principles of database design: getting this right to begin with will save a lot of time and effort later. There are numerous books on the subject, and OUCS’s IT Learning Programme runs regular courses both on general database design and on specific packages such as Access and Filemaker Pro: see http://www.oucs.ox.ac.uk/itlp/ for more information. Sorting and querying data Resear ch When you come to analyse your data, the chances are that you’ll want to use the database to answer various questions: how many items there are that fall into a particular category, for example, or how items in one category relate to those in another. Some straightforward questions can be answered by sorting or filtering the data within a specific table: for example, you could sort records into alphabetical order to group together the items that relate to each author, or you could filter the data so that only the records mentioning one particular author are shown. If you want to ask more complex questions, or to search across multiple tables, you can use a query: a set of instructions which tells the database program what you want to know. Database management systems include tools for building queries, and will generally also allow you to save a query for future reuse. A query-building tool will typically translate the instructions you give it into an underlying query language such as SQL (this stands for Structured Query Language: you may sometimes hear the acronym pronounced as three separate letters, and sometimes as ‘sequel’). You can also enter queries directly in SQL yourself, but it’s perfectly possible to use a software package such as Access with no knowledge of SQL. Forms and reports Database tables display a lot of information in a compact format, but they don't offer much flexibility, and they don't provide an ideal medium for viewing the contents of longer fields. Most database systems will therefore allow you to create custom screen layouts known as forms. These show one record at a time, and can be used for both viewing existing records and adding new ones. They provide a way of displaying some or all of a database's fields, arranged in a way that makes sense for a particular purpose. In particular, if your database contains images, forms often provide the best way of viewing these. If you want to produce a summary of all or part of a dataset, reports provide a way of doing this. A report might show the data in a particular table, a specified subset of fields, or the results of a query, presented in a format that’s suitable for printing or saving as a PDF. The layout and appearance of the report can be customised as desired. Most database management systems include tools to guide you through the process of producing a report that meets your needs. Database management systems – further information For more details of these software packages, see their websites: Microsoft Access: http://office.microsoft.com/en-gb/access/ – Commercial software for Windows. OpenOffice.org Base: http://www.openoffice.org/ – Free, open source software for Windows, Mac, and Linux. FileMaker Pro: http://www.filemaker.co.uk/ – Commercial software for Mac and Windows. Also available is an inexpensive Mac-only personal database program called Bento: http://www.filemaker.co.uk/products/bento/.