Docsity

Database Fundamentals and SQL: A Comprehensive Guide - Prof. mwiti, Study notes of Computer Science

Toggle sidebar
bg1
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
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58
pf59
pf5a
pf5b
pf5c
pf5d
pf5e
pf5f
pf60
pf61
pf62
pf63
pf64

Partial preview of the text

Download Database Fundamentals and SQL: A Comprehensive Guide - Prof. mwiti and more Study notes Computer Science in PDF only on Docsity!

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
  11. Understand database fundamentals
  12. Design a data base
  13. Use Structured Query Language
  14. Design of object oriented database
  15. Understand indexing and hashing
  16. 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 1.2 Terminologies used with databases are explained 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 Activities may be carried out in groups or as individual 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

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.

 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 LastNam e FirstName Age (^1) Hansen Ola 30 2 Svendson Tove 23 3 Pettersen Kari 20 "Orders" table: Orders table

OrderI D OrderNumbe r PersonI D 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.

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- 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.
  1. Specify the folder for storing the installation files that the installer will download, then click the Install button.
  2. The installer starts downloading the install package for a while.
  1. Click the first link to launch a wizard to install SQL Server 2017.
  1. Specify the edition that you want to install, select Developer edition and click the Next button.
  2. Select the “I accept the license terms.” and click the Next button.
  3. 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.
  1. Specify the name and install ID for the instance of the SQL Server and click the Next button.
  2. Specify the service account and collation configuration. Just use the default configuration and click the Next button.
  1. 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.
  2. Verify the SQL Server 2017 features to be installed:
  1. Once it completes, the following window displays. Click the OK button.
  2. 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