Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views32 pages

Database Note 1

Uploaded by

mwangialex395
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views32 pages

Database Note 1

Uploaded by

mwangialex395
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 32

CHAPTER 6: DATABASE MANAGEMENT SKILLS

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.

6.2 Performance Standard


1. Installed MS SQL server
2. Created an entity relationship model
3. Normalized database tables
4. Validated an ER model
5. Created and queried a database from a validated ER model.
6. Retrieved data from several tables using joins
7. Prescribed a database type based on user requirements.
8. Demonstrated Object Oriented Concepts
9. Demonstrated designing of views and triggers in object oriented databases.
10. Implemented Indexing and hashing

6.3 Learning Outcomes


6.3.1 List of Learning Outcomes
1. Understand database fundamentals
2. Design a data base
3. Use Structured Query Language
4. Design of object oriented database
5. Understand indexing and hashing
6. Understand database applications
6.3.2 Learning Outcome 1: Understand database fundamentals
6.3.2.1 Learning Activities
Learning Outcome 1: Understand database fundamentals
Learning Activities Special Instructions

1.1 A database is defined Activities may be carried out in


1.2 Terminologies used with databases are explained groups or as individual
1.3 Reasons of using databases are explained
1.4 Relational Model is defined
1.5 Key concepts in relational modelling are explained
1.6 Properties of a table/relation are explained
1.7 Relational Database Management Systems (RDBMSs)
products are compared
1.8 Installation of MS SQL server is demonstrated
1.9 MS SQL server interface is explained
1.10 Properties of MS SQL server database are explained

6.3.2.2 Information Sheet No 6:LO1: Understand database fundaments


Introduction

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

Figure 1: MSAccess Database Sample


Database terminologies

 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.

Figure 2:: MSAccess Table Sample

 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.

Figure 3: : MSAccess Table Records Sample

 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.

Figure 4:: MSAccess Table Fields Sample.

Reasons of using databases


The various reasons a database is important are:
Manages large amounts of data
A database stores and manages a large amount of data on a daily basis. This would
not be possible using any other tool such as a spreadsheet as they would simply not
work.

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.

Easy to update data


In a database, it is easy to update data using various Data Manipulation languages
(DML) available. One of these languages is SQL.

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.

Easy to research data


It is very easy to access and research data in a database. This is done using Data
Query Languages (DQL) which allow searching of any data in the database and
performing computations on it.

Control of data redundancy


In the database approach, ideally, each data item is stored in only one place in the
database. In some cases, data redundancy still exists to improve system performance,
but such redundancy is controlled by application programming and kept to minimum
by introducing as little redundancy as possible when designing the 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.

Backup and recovery facilities


Backup and recovery are methods that allow you to protect your data from loss. The
database system provides a separate process, from that of a network backup, for
backing up and recovering data. If a hard drive fails and the database stored on the
hard drive is not accessible, the only way to recover the database is from a backup.

Support for multiple views of data


A database supports multiple views of data. A view is a subset of the database, which
is defined and dedicated for particular users of the system. Multiple users in the
system might have different views of the system. Each view might contain only the
data of interest to a user or group of users.

Insulation between program and data


In the file-based system, the structure of the data files is defined in the application
programs so if a user wants to change the structure of a file, all the programs that
access that file might need to be changed as well. On the other hand, in the database
approach, the data structure is stored in the system catalogue and not in the programs.
Therefore, one change is all that is needed to change the structure of a file. This
insulation between the programs and data is also called program-data independence.

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

In the above-given example, employee ID is a primary key because it uniquely identifies an


employee record. In this table, no other employee can have the same employee ID.
 Foreign Key
A FOREIGN KEY is a key used to link two tables together.
A FOREIGN KEY is a field (or collection of fields) in one table that refers to the
PRIMARY KEY in another table. The table containing the foreign key is called the child
table, and the table containing the candidate key is called the referenced or parent table.
Look at the following two tables:

"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

Relational tables have six properties:


Values Are Atomic
This property implies that columns in a relational table are not repeating group or arrays.
Such tables are referred to as being in the "first normal form" (1NF). The atomic value
property of relational tables is important because it is one of the cornerstones of the
relational model.
The key benefit of the one value property is that it simplifies data manipulation logic.

Column Values Are of the Same Kind


In relational terms this means that all values in a column come from the same domain. A
domain is a set of values which a column may have. For example, a Monthly_Salary
column contains only specific monthly salaries. It never contains other information such as
comments, status flags, or even weekly salary.
This property simplifies data access because developers and users can be certain of the type
of data contained in a given column. It also simplifies data validation. Because all values
are from the same domain, the domain can be defined and enforced with the Data
Definition Language (DDL) of the database software.

Each Row is Unique


This property ensures that no two rows in a relational table are identical; there is at least
one column, or set of columns, the values of which uniquely identify each row in the table.
Such columns are called primary keys.
This property guarantees that every row in a relational table is meaningful and that a
specific row can be identified by specifying the primary key value.

e Sequence of Columns is Insignificant


This property states that the ordering of the columns in the relational table has no meaning.
Columns can be retrieved in any order and in various sequences. The benefit of this
property is that it enables many users to share the same table without concern of how the
table is organized. It also permits the physical structure of the database to change without
affecting the relational tables.

The Sequence of Rows is Insignificant


This property is analogous the one above but applies to rows instead of columns. The main
benefit is that the rows of a relational table can be retrieved in different order and
sequences. Adding information to a relational table is simplified and does not affect
existing queries.

Each Column Has a Unique Name


Because the sequence of columns is insignificant, columns must be referenced by name and
not by position. In general, a column name need not be unique within an entire database
but only within the table to which it belongs.

Comparison of RDBMS products


 Oracle
Oracle Corporation owns Oracle Database, and the code is not open sourced.

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)

Installation of MS SQL server


Beginning with SQL Server 2016 (13.x), SQL Server is only available as a 64-bit application.
Here are important details about how to get SQL Server and how to install it.

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

Install SQL Server 2017 Developer Edition


To install SQL Server, you need to download it from the Microsoft.com website via the
following link: https://www.microsoft.com/en-us/sql-server/sql-server-2017
Once the download completes, you double-click the file SQLServer2017-SSEI-Dev.exe to
launch the installer.

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.

15. Verify the SQL Server 2017 features to be installed:


16. The installer starts the installation process
17. Once it completes, the following window displays. Click the OK button.

18. Click the Close button to complete the installation

Congratulation! you have successfully installed SQL Server Developer Edition.


Install Microsoft SQL Server Management Studio
To interact with SQL Servers, you need to install SQL Server Management Studio (SSMS).
The SQL Server Management Studio is a software for querying, designing, and managing
SQL Server on your local computer or in the cloud. It provides you with tools to configure,
monitor, and administer SQL Server instances.

First, download the SSMS from the Microsoft website via the following link:
Download SQL Server Management Studio

Second, double-click the installation file SSMS-Setup-ENU.exe to starting installing. The


installation process of SMSS is straightforward which you just need to follow the screen
sequence.

1. Click the Install button

2. Wait for few minutes while the installer sets up the software.

3. Once setup is completed, click the Close button


Now, you should have a SQL Server 2017 and SQL Server Management Studio installed on
your computer.

MS SQL server interface


Normally, when you install Microsoft SQL Server, you also install the SQL Server
Management Studio (SSMS), which is the primary tool for managing the server and its
databases using a graphical interface.

Figure 5:: MSSQL Server Interface

 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:

o Here's a Horizontal Tab Group:

o Here's a Vertical Tab Group:


o To merge the tabs, right-click the query title, and then select Move to Previous Tab
Group or Move to Next Tab Group:

 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.

Change basic settings


This section describes how to modify some basic settings in SSMS from the Tools menu.

 To modify the highlighted toolbar, select Tools > Customize:


Change the font
 To change the font, select Tools > Options > Fonts and Colors:

Change startup options


 Startup options determine what your workspace looks like when you first open SSMS.
To change startup options, select Tools > Options > Startup:
Reset settings to the default
 You can export and import all these settings from the menu. To import or export
settings, or to restore default settings, select Tools > Import and Export Settings

Properties of MS SQL server Database


The following a properties apply to a SQL server database. From the object explorer, right
click on an existing database to see the properties as follows:
 Deleting a database
 Deleting data or log files
 Increasing database size
 Shrinking database
 Renaming database
 Importing a database
 Exporting a database

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

1 A relational database consists of a collection of


a)Tables
b)Fields
c)Records
d) Keys
2 A ________ in a table represents a relationship among a set of values.
a)Column
b)Key
c)Row
d) Entry
3 The term _______ is used to refer to a row.
a)Attribute
b)Tuple
c)Field
d) Instance
4 The term attribute refers to a ___________ of a table.
a)Record
b)Column
c)Tuple
d) Key
5 For each attribute of a relation, there is a set of permitted values, called the ________ of
that attribute.
a)Domain
b)Relation
c)Set
d) Schema
6 Course(course_id,sec_id,semester)
Here the course_id,sec_id and semester are __________ and course is a _________
a)Relations,Attribute
b)Attributes,Relation
c)Tuple,Relation
d) Tuple, Attributes
7 A _____ is a property of the entire relation, rather than of the individual tuples in which
each tuple is unique.
a)Rows
b)Key
c)Attribute
d) Fields
8 Which one of the following attribute can be taken as a primary key?
a)Name
b)Street
c)Id
d) Department
9 Which one of the following cannot be taken as a primary key?
a)Id
b)Register number
c)Dept_id
d) Street
10 Which language can a user request information from a database with?
a)Query
b)Relational
c)Structural
d) Compiler
11 Student(ID, name, dept name, tot_cred)
In this statement which attributes form the primary key?
a)Name
b)Dept
c)Tot cred
d) ID
12 Database __________ which is the logical design of the database, and the database
_______ which is a snapshot of the data in the database at a given instant in time.
a) Instance, Schema
b) Relation, Schema
c) Relation, Domain
d) Schema, Instance

Oral Assessment

1. Explain 5 applications of databases in your real life


2. Explain 5 properties of a relational database

Practical Assesssment

1. In groups of two install MS SQL server on your personal Laptop


2. Document the steps of installing MS SQL Server as you install.

6.3.2.4 Tools, Equipment, Supplies and Materials


 Microsoft Office with MS Visio Modelling tool
 MS SQL server software
 Computers
 Instruction material
 Stationery
 Internet

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)

You might also like