(cache)AL ICT - Databse | PDF | Relational Database | Relational Model
0% found this document useful (0 votes)
4K views39 pages

AL ICT - Databse

Database

 
N.K Waruna Devaka(BIT
 –
 UCSC)
1
Competency 8
Designs and develops database systems to manage data efficiently and effectively. 8.1 The basics of information and data, and the need for databases.
 
Data vs. information
Data is a raw and unorganized fact that is required to be processed to make it meaningful whereas Information is a set of data that is processed in a meaningful way according to the given requirement.
Structured Vs. unstructured data
Structured data is highly-organized and formatted so that it's easily searchable in relational databases. Unstructured data has no predefined format or organization, making it much more difficult to collect, process, and analyze.
Database
A database is an organized collection of structured information, or data, typically stored electronically in a computer system. A database is usually controlled by a database management system (DBMS).
Database models
 
A flat file database
 is basically a giant collection of data in which the tables and records have no relation between any other tables. In fact, one could have a single table.
 
A hierarchical database model
 is a data model in which the data are organized into a tree-like structure. The data are stored as records which are connected to one another through links. A record is a collection of fields, with each field containing only one value.
 
Network Model
 is an extension of the Hierarchical model. In this model data is organised more like a graph, and are allowed to have more than one parent node.
 
Relational Model
 represents how data is stored in Relational Databases. A relational database stores data in the form of relations (tables).
 
Object relational model
 is a combination of a Object oriented database model and a Relational database model. So, it supports objects, classes, inheritance etc. just like
 
N.K Waruna Devaka(BIT
 –
 UCSC)
2
Object Oriented models and has support for data types, tabular structures etc. like Relational data model.
8. 2 The main components of the relational database model. Relations / Tables
A table is a collection of logically related information treated as a unit. Tables are organized by rows and columns.
 
Record or Tuple:
Each row of a table is known as record. It is also known as tuple.
 
 
Attributes or Columns :
Each column in a Table. Attributes are the properties which define a relation. e.g., Student_Rollno, Name, Address.
 
 
Degree :
The total number of attributes which in the relation is called the degree of the relation.
 
 
Cardinality :
Total number of rows present in the Table.
 
 
N.K Waruna Devaka(BIT
 –
 UCSC)
3
Types of Constraints
Constraints are the set of rules that ensures that when an authorized user modifies the database they do not disturb the data consistency.
 
A NOT NULL Constraint :
Ensure that a given column of a table is never assigned the null value(empty value).
 
 
A Unique Constraint :
Ensures that all values in a column are different.
 
 
A Primary Key Constraint :
The primary key constraint uniquely identifies each record in a table. Primary keys must contain unique values, and cannot contain null values.
 
 
A Foreign Key Constraint :
The foreign key constraint is used to prevent actions that would destroy links between tables. A foreign key is a field (or collection of fields) in one table, that refers to the primary key in another table.
 
 
A (Table) Check Constraint :
The check constraint is used to limit the value range that can be placed in a column.
 8.3 The main component of a database system. A database management system
A database management system (DBMS) is a software package designed to define, manipulate, retrieve and manage data in a database. A DBMS generally manipulates the data itself, the data format, field names, record structure and file structure. It also defines rules to validate and manipulate this data. Some DBMS examples include MySQL, PostgreSQL, Microsoft Access, SQL Server, FileMaker, Oracle, RDBMS, dBASE, Clipper, and FoxPro.
Structured Query Language(SQL)
Structured Query Language is a computer language for storing, manipulating and retrieving data stored in a relational database. SQL is the standard language for Relational Database System.
 
SQL statements are divided into two major categories: data definition language (DDL) and data manipulation language (DML).
SQL
 
N.K Waruna Devaka(BIT
 –
 UCSC)
4
Data definition language (DDL)
Data definition language (DDL) refers to the set of SQL commands that can create and manipulate the structures of a database. DDL statements are used to create, change, and remove objects including indexes, triggers, tables, and views. Common DDL statements include:
 
CREATE (generates a new table)
 
ALTER (add, delete, or modify columns/constrains in an existing table)
 
DROP (removes a table/ database)
1) CREATE Statement
The SQL CREATE DATABASE Statement :
The CREATE DATABASE statement is used to create a new SQL database.
 
Syntax -
CREATE DATABASE
databasename
;
 
Example - CREATE DATABASE testDB;
 The SQL CREATE TABLE Statement :
The CREATE TABLE statement is used to create a new table in a database.
Syntax Example
CREATE TABLE
table_name
(
column1 datatype
,
column2 datatype
,
column3 datatype
, .... );
 
CREATE TABLE Persons ( PersonID int, LastName varchar(255), FirstName varchar(255), Address varchar(255), City varchar(255) );
 
SQL Data Types
o
 
VARCHAR(size) : A VARIABLE length string (can contain letters, numbers, and special characters).
o
 
CHAR(size) :
 
A FIXED length string (can contain letters, numbers, and special characters).
o
 
INT(size):
 
A medium integer.
o
 
DATE:
 
A date. Format: YYYY-MM-DD.

Share this document

Millions of documents at your fingertips, ad-free Subscribe with a free trial

You might also like

576648e32a3d8b82ca71961b7a986505