Database Note 1
Database Note 1
6.1 Introduction
This unit covers the competencies required to demonstrate database management skills. It
involves understanding database fundamentals, designing a database, using Structured
Query Language, understanding the design of object oriented databases, understanding
indexing and hashing and understanding database applications.
This learning outcome covers the definition of database, relational model and other
terminologies used in databases. It also explains the reasons for using databases, key concepts
in relational modelling, properties of tables and the MS SQL server interface. It also involves
comparing relational database management systems, demonstrating MS SQL server
installation and explaining MS SQL server database properties.
Database
A Database is a collection of related data organised in a way that data can be easily
accessed, managed and updated. Database can be software based or hardware based, with
one sole purpose, storing data
Table
A database table is composed of records and fields that hold data. Tables are also called
datasheets. Each table in a database holds data about a different, but related, subject.
Database engine
A database engine (or storage engine) is the underlying software component that a
database management system (DBMS) uses to create, read, update and delete (CRUD)
data from a database. ... The term "database engine" is frequently used interchangeably
with "database server" or "database management system".
Records
Data is stored in records. A record is composed of fields and contains all the data about one
particular person, company, or item in a database. In this database, a record contains the data
for one customer support incident report. Records appear as rows in the database table. A
record for Log ID 1201242 is highlighted in below.
Field
A field is part of a record and contains a single piece of data for the subject of the record. In
the database table illustrated in Figure below, each record contains four fields:
Log ID A number assigned to this customer support incident for
identification purposes
Operator The code for the customer support operator who handled
this incident
Resolved A check box to indicate whether the incident was resolved
Duration The time in seconds the operator spent on this incident
Fields appear as columns in a database table. Data from the Log ID field for five records is
highlighted in the Figure below.
Accurate
A database is pretty accurate as it has all sorts of build in constraints, checks etc. This
means that the information available in a database is guaranteed to be correct in most
cases.
Security of data
Databases have various methods to ensure security of data. There are user logins
required before accessing a database and various access specifiers. These allow only
authorised users to access the database.
Data integrity
This is ensured in databases by using various constraints for data. Data integrity in
databases makes sure that the data is accurate and consistent in a database.
Data sharing
The integration of all the data, for an organization, within a database system has many
advantages. First, it allows for data sharing among employees and others who have access
to the system. Second, it gives users the ability to generate more information from a given
amount of data than would be possible without the integration.
Data independence
Another advantage of a database management system is how it allows for data
independence. In other words, the system data descriptions or data describing data
(metadata) are separated from the application programs. This is possible because changes
to the data structure are handled by the database management system and are not embedded
in the program itself.
Relational model
The relational model represents the database as a collection of relations. A relation is
nothing but a table of values. In this model, data is organised in two-dimensional
tables and the relationship is maintained by storing a common field.
.
Relational Modeling Concepts
Relations/tables
A relational database system contains one or more objects called tables or relations. The
data or information for the database are stored in these tables. Tables are uniquely
identified by their names and are comprised of columns and rows. Columns contain the
column name, data type, and any other attributes for the column. Rows contain the records
or data for the columns. Here is a sample table called "weather". City, state, high, and low
are the columns. The rows contain the data for this table:
Weather
city state high low
Phoenix Arizona 105 90
Tucson Arizona 101 92
Flagstaff Arizona 88 69
San Diego California 77 60
New
Albuquerque 80 72
Mexico
Table Weather
Attributes/Columns
Each named column in a Table is an attribute. Attributes are the properties which define a
relation. e.g., Student_Rollno, NAME, etc.
Domain
A domain is the original sets of atomic values used to model data. By atomic value, we
mean that each value in the domain is indivisible as far as the relational model is
concerned. For example:
The domain of Marital Status has a set of possibilities: Married, Single, Divorced.
The domain of Shift has the set of all possible days: {Mon, Tue, Wed…}.
The domain of Salary is the set of all floating-point numbers greater than 0 and less
than 200,000.
The domain of First Name is the set of character strings that represents names of
people.
In summary, a domain is a set of acceptable values that a column is allowed to contain.
This is based on various properties and the data type for the column. We will discuss data
types in another chapter.
Tuples/Rows
A row—also called a tuple—represents a single, implicitly structured data item in a table.
Each row in a table represents a set of related data, and every row in the table has the same
structure.
Primary Key
A primary key is a field in a table which uniquely identifies each row/record in a
database table. Primary keys must contain unique values. A primary key column cannot
have NULL values. A table can have only one primary key, which may consist of single
or multiple fields.
.
Example:
Employee ID FirstName LastName
11 Andrew Johnson
22 Tom Wood
33 Alex Hale
Demonstration of a Primary Key
"Persons" table:
Persons table
PersonID LastName FirstName Age
1 Hansen Ola 30
2 Svendson Tove 23
3 Pettersen Kari 20
"Orders" table:
Orders table
OrderID OrderNumber PersonID
1 77895 3
2 44678 3
3 22456 2
4 24562 1
Notice that the "PersonID" column in the "Orders" table points to the "PersonID"
column in the "Persons" table.
The "PersonID" column in the "Persons" table is the PRIMARY KEY in the
"Persons" table.
The "PersonID" column in the "Orders" table is a FOREIGN KEY in the "Orders"
table.
The FOREIGN KEY constraint is used to prevent actions that would destroy links
between tables.
The FOREIGN KEY constraint also prevents invalid data from being inserted into the
foreign key column, because it has to be one of the values contained in the table it
points to.
Properties of a relation/table
Oracle DB is for large applications, particularly in the banking industry. Most of the world’s
top banks run Oracle applications because Oracle offers a powerful combination of
technology and comprehensive, pre-integrated business applications, including essential
functionality built specifically for banks.
The main disadvantage of using Oracle is that it is not free to use like its open source
competitors and can be quite expensive.
MS SQL server
Microsoft owns SQL Server. Like Oracle DB, the code is close sourced. Large enterprise
applications mostly use SQL Server.
Microsoft offers a free entry-level version called Express but can become very expensive as
you scale your application.
My SQL
MySQL is the most popular open source SQL database. It is typically used for web
application development, and often accessed using PHP.
The main advantages of MySQL are that it is easy to use, inexpensive, reliable (has been
around since 1995), and has a large community of developers who can help answer questions.
Some of the disadvantages are that it has been known to suffer from poor performance when
scaling, open source development has lagged since Oracle has taken control of MySQL, and
it does not include some advanced features that developers may be used to
.
Ms Access
Microsoft Access is a Database Management System offered by Microsoft. It uses the
Microsoft Jet Database Engine and comes as a part of the Microsoft Office suite of
application.
Microsoft Access offers the functionality of a database and the programming capabilities to
create easy to navigate screens (forms)
Editions and features: Review the supported features for the different editions and versions
of SQL Server to determine which best suits your business needs.
SQL Server 2019 (15.x).
SQL Server 2017 (14.x).
SQL Server 2016 (13.x).
SQL Server 2014 (12.x)
Requirements: Review installation requirements, system configuration checks, and security
considerations in Planning a SQL Server Installation
1. The installer asks you to select the installation type, choose the Custom installation type
allows you to step through the SQL Server installation wizard and select the features that you
want to install.
2. Specify the folder for storing the installation files that the installer will download, then
click the Install button.
3. The installer starts downloading the install package for a while.
4. Once the download completes, open the folder that stores the install package and double-
click the SETUP.exe file.
5. The following window displays; select the installation option on the left.
6. Click the first link to launch a wizard to install SQL Server 2017.
7. Specify the edition that you want to install, select Developer edition and click the Next
button.
8. Select the “I accept the license terms.” and click the Next button.
9. Check the “Use Microsoft Update to check for updates (recommended)” to get the security
and other important updates for the SQL Server and click the Next button.
10. The installation checks for the prerequisites before installation. If no error found, click the
Next button.
11. Select the features that you want to install. For now, you just need the Database Engine
Services, just check the checkbox and click the Next button to continue
12. Specify the name and install ID for the instance of the SQL Server and click the Next
button.
13. Specify the service account and collation configuration. Just use the default configuration
and click the Next button.
14. Specify the database engine security mode. First, choose Mixed Mode. Next, enter the
password for the SQL Server system administrator (sa) account. Then, re-enter the same
password to confirm it. After that, click the Add Current User button. Finally, click the Next
button.
First, download the SSMS from the Microsoft website via the following link:
Download SQL Server Management Studio
2. Wait for few minutes while the installer sets up the software.
Object Explorer (F8): Object Explorer is a tree view of all the database objects in a
server. This view includes the databases of the SQL Server Database Engine, SQL
Server Analysis Services, SQL Server Reporting Services, and SQL Server Integration
Services. Object Explorer includes information for all servers that are connected to it.
Query Window (Ctrl+N): After you select New Query, enter your Transact-SQL (T-
SQL) queries in this window. The results of your queries also appear here.
Properties (F4): You can see the Properties view when the Query Window is open.
The view displays basic properties of the query. For example, it shows the time that a
query started, the number of rows returned, and connection details.
Template Browser (Ctrl+Alt+T): Template Browser has various pre-built T-SQL
templates. You can use these templates to perform various functions, such as creating
or backing up a database.
Object Explorer Details (F7): This view is more granular than the view in Object
Explorer. You can use Object Explorer Details to manipulate multiple objects at the
same time. For example, in this window, you can select multiple databases, and then
either delete them or script them out simultaneously.
Change the environment layout
This section describes how to change the environment layout, such as how to move various
windows.
To move a window, press and hold the title, and then drag the window.
To pin or unpin a window, select the pushpin icon in the title bar:
Each window component has a drop-down menu that you can use to manipulate the
window in various ways:
When two or more query windows are open, the windows can be tabbed vertically or
horizontally so that both query windows are visible. To view tabbed windows, right-
click the title of the query, and then select the tabbed option that you want:
To restore the default environment layout, in the Window menu, select Reset Window
Layout:
Maximize Query Editor
You can maximize Query Editor to full-screen mode:
1. Click anywhere in the Query Editor window.
2. Press Shift+Alt+Enter to toggle between full-screen mode and regular mode.
This keyboard shortcut works with any document window.
Conclusion
At the end of this learning outcome, the learner should be able to define of database,
relational model and other terminologies used in databases. The learner should also be able to
explain the reasons for using databases, key concepts in relational modelling, properties of
tables and the MS SQL server interface. In addition, a learner should be able to compare
relational database management systems, demonstration of MS SQL server installation and
explanation of MS SQL server database properties should be one.
Further Reading
1. Elmasri, R., & Navathe, S. B. (2011). Database systems (Vol. 9). Boston, MA:
Pearson Education.
2. Hoffer, J. A., Ramesh, V., & Topi, H. (2011). Modern database management. Upper
Saddle River, NJ: Prentice Hall,.
3. Rankins, R., Jensen, P., & Bertucci, P. (2002). Microsoft SQL Server 2000
Unleashed. Sams Publishing.
4. Davidson, L. (2001). Professional SQL server 2000 database design. Birmingham,
UK: Wrox Press.
6.3.2.3 Self-Assessment
Written Assessment
Oral Assessment
Practical Assesssment
6.3.2.5 References
1. https://www.guru99.com/dbms-tutorial.html
2. https://www.cengage.com/school/corpview/RegularFeatures/DatabaseTutorial/
db_elements/db_elements2.htm
3. https://www.cs.wcupa.edu/~zjiang/RDB_table.htm(Retrieved on 2nd March 2020)