You are on page 1of 13

Yusif Suleiman

Q1

2308-0703-0223

(a). Database
Database is a collection of data, information that is organized so that it can easily be accessed, managed, and updated. Database is also define as information organized in such a way that a computer program can quickly select desired pieces of data or information. You can think of a database as an electronic filing system. In one view, databases can be classified according to types of content of information or data types it store. The types of data types are Text, Number, Currency, Date/time, Memo, Hyperlink, OLE object, AutoNumber and Yes/No. In computing, databases are sometimes classified according to their organizational approach. The most prevalent approach is the relational database, a tabular database in which data is defined so that it can be reorganized and accessed in a number of different ways. A distributed database is one that can be dispersed or replicated among different points in a network. An object-oriented programming database is one that is congruent with the data defined in object classes and subclasses. Computer databases typically contain aggregations of data records or files, such as sales transactions, product catalogs and inventories, customer profiles and patient record. Typically, a database manager provides users the capabilities of controlling read/write access, specifying report generation, and analyzing usage. Databases and database managers are prevalent in large mainframe systems, but are also present in smaller distributed workstation, mid-range systems and personal computers. SQL (Structured Query Language) is a standard language for making interactive queries from and updating a database. Database consist of two things program and tools which assist the user manage logically related data organized in a manner that allow access, retrieval, used and maintenance.

An alternative concept in database design is known as Hypertext. In a Hypertext database, any object, whether it be a piece of text, a picture, or a film, can be linked to any other object. Hypertext databases are particularly useful for organizing large amounts of disparate information, but they are not designed for numerical analysis. Database

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

Management System (DBMS) is a program/software which assist us to design, manage, access, information from a database. databases are normally organized by fields, records, and files. A field is a single piece of information, a record is one complete set of fields, and a file is a collection of records. For example, a Hospitals Patient Record book is equivalent to a file. It contains a list of records, each of which consists of different fields where we select UnitNumber as Primary Key, the below example illustrate how the database is design, organized using Access. Primary key

Field

Column

Row

Advantages of Database
Reduced data redundancy, Improved data security Reduced updating errors and increased consistency Greater data integrity and independence from applications programs Improved data access to users through use of host and query languages Reduced data entry, storage, and retrieval costs

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman
Facilitated development of new applications program

2308-0703-0223

Disadvantages of database
Database systems are complex, difficult, and time-consuming to design Substantial hardware and software start-up costs Damage to database affects virtually all applications programs Extensive conversion costs in moving form a file-based system to a database system Initial training required for all programmers and users

(b). Table
Tables is consist of rows/tuples and columns or attribute of well-defined data types. A table stores organized structured data in a database. Data in a table is organized in rows or database records. Each row contains columns or fields. Each field has a type, such as AutoNumber, Memo, Text, Currency, Number, Hyperlink, OLE Object, Date/Time, or Yes/No. Database tables are similar to other tables such as the table of spreadsheet cells or in a text document. However they are not the same. Database tables are the most restrictive in the structure of the data they accept, including keys and conditions such as unique or not null. Data in tables is often viewed and entered with form and some programming logic forming a database application, tables in databases are sometimes classified according to their organizational approach. The most prevalent approach is the relational database, a tabular database in which data is defined in table so that it can be reorganized and accessed in a number of different ways. A table in database is one that can be dispersed or replicated among different points in a network. In an organization that require many details from particular object and deal with different classes items, product, or public each object/person in case of hospital patient data table could have a description attribute that declared and specify the column, example below

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

shows the table from the hospital patient database as record table, which contain different attribute to identify the patient details such as UnitNumber, FirstName, LastName, Age, Sex, Address, Diagnosis and Clinics. Attribute Column

Row

(c). Attributes
Attributes are data items that describe an entity, are also known as Column in database. An attribute instance is a single value of an attribute for an instance of an entity. For example, Name and Diagnosis are attributes of the entity MEDICALCLINIC. "Auwal Shehu" and "Hypertension" are instances of the attributes name and diagnosis. The primary key is an attribute or a set of attributes that uniquely identify a specific instance of an entity. Every entity in the data model must have a primary key whose values uniquely identify instances of the entity. A column-oriented DBMS is a database management system (DBMS) which stores its content by column rather than by row. This has advantages for databases such as data warehouses and library catalogues, where aggregates are computed over large numbers of similar data items. In the context of a relational database table, a column or attribute is a set of data values of a particular simple type, one for each row of the table. The columns provide the structure according to which the rows are composed.

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

For example, a table that represents Hospital Patient Record might have the following columns: PatientID (Number identifier, unique to each row), Name(text), Sex(text), Age(Number), Address(text), and Diagnosis(text). Clinic(text identifier, drawn from a separate table of clinic, from which any type of sickness or diagnosis information would be drawn). Each row would provide a data value for each column and would then be understood as a single structured data value, in this case representing a company. More formally, each row can be interpreted as a relvar, composed of a set of tuples, with each tuple consisting of the two items: the name of the relevant column as attribute and the value this row provides for that column consider the following example.
Table Attribute

(d). Tuples
Tuples is also known as Rows, it represent a single, implicitly structured data item in a table. In simple terms, a database table can be thought of as consisting of rows and columns or fields. Each row in a table represents a set of related data, and every row in the table has the same structure. The row is then interpreted as a relvar composed of a set of tuples, with each tuple consisting of the two items, the name of the relevant column and the value this row provides for that column. Each column expects a data value of a particular type. For example, one column might require a unique identifier, another might require text representing a person's name, another might require an Number representing UnitNumber. For example, in a table that represents companies, each row would represent a single company. Columns might represent things like company name, company street address, whether the company is publicly held, its VAT number, etc.. In a table that represents the

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

hospital patient with sickness, each row would associate one Patient name with one sickness as Diagnosis.

Name of relevant column

Value of tuple/row

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman
(e). Relational Database

2308-0703-0223

Relational database is a collection of data items organized as a set of formally-described tables from which data can be accessed or reassembled in many different ways without having to reorganize the database tables. Relational Database is a database constituting a set of relations. Relational databases are powerful because they require few assumptions about how data is related or how it will be extracted from the database. As a result, the same database can be viewed in many different ways. An important feature of relational systems is that a single database can be spread across several relations.

relational database is a set of tables containing data fitted into predefined categories. Each table (which is sometimes called a relation) contains one or more data categories in columns. Each row contains a unique instance of data for the categories defined by the columns. For example, a typical business order entry database would include a table that described a customer with columns for name, address, phone number, and so forth. Another table would describe an order: product, customer, date, sales price, and so forth. A user of the database could obtain a view of the database that fitted the user's needs. For example, a branch office manager might like a view or report on all customers that had bought products after a certain date. A financial services manager in the same company could, from the same tables, obtain a report on accounts that needed to be paid. When creating a relational database, you can define the domain of possible values in a data column and further constraints that may apply to that data value. For example, a domain of possible Hospital Patient Records could allow up to several possible patients names but be constrained in one table to allowing only specific of these patient names to be specifiable.

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

The tables above show the relationship between hospital patients record and specific different patient clinic name.

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman
(f). Primary Keys

2308-0703-0223

Primary key is used to uniquely identify each row in a table. It can either be part of the actual record itself , or it can be an artificial field (one that has nothing to do with the actual record) ie AutoNumber. A primary key may not contain null value, it can also consist of one or more fields on a table. When multiple fields are used as a primary key, they are called a composite key.

The primary key of a relational table uniquely identifies each record in the table. It can either be a normal attribute that is guaranteed to be unique (such as Social Security Number in a table with no more than one record per person) or it can be generated by the DBMS (such as a globally unique identifier, or GUID, in Microsoft SQL Server). Primary keys may consist of a single attribute or multiple attributes in combination. There would be multiple records for each patient (representing all the clinics that patient is attending) and multiple records for each clinics session (representing all the patient attending in that clinic). A patient's unique UnitNumber would be a good choice for a primary key in the PATIENT RECORD table. The Patient FirstName and LastName would not be a good choice, as there is always the chance that more than one Patient might have the same name. The table below shows the unique primary key as ClinicNumber. Primary key

To qualify as a primary key for an entity, an attribute must have the following properties:

It must have a non-null value for each instance of the entity The value must be unique for each instance of an entity The values must not change or become null during the life of each entity instance

Informatics Academy

C1025 SQL Assignment

Yusif Suleiman
(g). Composite Keys

2308-0703-0223

Composite key is a combination of more than one attribute to uniquely identify an entity/table in the database. Sometimes it requires more than one attribute to uniquely identify an entity. When multiple fields are used as a primary key, they are called a composite key. A composite key is a primary key that consists of more than one column. Also known as a concatenated key or aggregate key Imagine we have a student records database that contains three tables. The first table, STUDENTS, contains a record for each student at the university. The second table, CLASSES, contains a record for each class session offered. The third table, ENROLLMENT, contains student enrollment records (e.g. each record represents a single student enrolling in a single course). In the following laboratory table record, we may have two patient with two different test, so combination of two more attribute as primary key is consider.

Two attribute selected as Primary key(Composite key)

Advantages of Composite Keys


A composite key provides opportunities for index covering. A composite key is a good way to enforce the uniqueness of multiple attributes. If queries provide search arguments on each of the keys, the composite keys requires fewer I/Os than the same query using an index on any single attribute.

Disadvantages of Composite Key

Composite keys tend to have large entries. This means fewer index entries per index page and more index pages to read.

Informatics Academy

10

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

An update to any attribute of a composite index causes the index to be modified. The columns you choose should not be those that are updated often.

(h). Foreign Keys


Foreign key is a field (or fields) that points to the primary key of another table, is a referential constraint between two tables. The foreign key identifies a column or a set of columns in one (referencing) table that refers to a column or set of columns in another (referenced) table. The columns in the referencing table must be the primary key in the referenced table. The values in one row of the referencing columns must occur in a single row in the referenced table. Thus, a row in the referencing table cannot contain values that don't exist in the referenced table (except potentially NULL). This way references can be made to link information together and it is an essential part of database normalization. Multiple rows in the referencing table may refer to the same row in the referenced table. Most of the time, it reflects the one (master table, or referenced table) to many (child table, or referencing table) relationship. The referencing and referenced table may be the same table, i.e. the foreign key refers back to the same table. A table may have multiple foreign keys, and each foreign key can have a different referenced table. Each foreign key is enforced independently by the database system. Therefore, cascading relationships between tables can be established using foreign keys. Improper foreign key/primary key relationships or not enforcing those relationships are often the source of many database and data modeling problems.

Purpose of the foreign key


Is to ensure referential integrity of the data. Only values that are supposed to appear in the database are permitted.

In this arrangement, a primary key in the first table will typically refer to the foriegn key of the second table. This enables references which can be made to link information together.

Informatics Academy

11

C1025 SQL Assignment

Yusif Suleiman

2308-0703-0223

Primary key

Foreign key Primary key

Advantages of Foreign Keys

Centralizing the checking of these constraints by the database server makes it unnecessary to perform these checks on the application side. This eliminates the possibility that different applications may not check constraints in the same way.

Using cascading updates and deletes can simplify the application code. Properly designed foreign key rules aid in documenting relationships between tables.

Informatics Academy

12

C1025 SQL Assignment

Yusif Suleiman
Disadvantages of Foreign Keys

2308-0703-0223

On primary key index will be created so during updation of table index need to be adjusted accordingly. this process makes the updation slower.

There can be more than one keys on which all the other attributes are dependent on.

Informatics Academy

13

C1025 SQL Assignment

You might also like