BASUKI BUDIJANI…. Untuk mahasiswaku / siswaku tercinta
SQL SERVER 2008
DATABASE:
A database is a collection of information that is organised
so that it can be easily accessed, managed and updated.
ANOTHER
DEFINITION OF DATABASE:
A stuctured
set of data held in a computer, especially one that is accexxible in various
ways.
DATABASE
TABLE:
Database
table is a tabular format format and it is used to store the dat of our
application, sofware, orgaization etc.
Table
is made of rows and columns.
A row
represents a record.
A column
represents a field.
SQL is a
standard language for storing, manipulating and retriieving data in databases.
What is SQL?
SQL stands
for structured query language
SQL lets you
access and manipulate databases
SQL is an
ANSI ( american national stadards institute ) standard.
What can SQL
do ?
SQL can
execute wueries against a database
SQL can retrieve data from a datbase
SQL can
insert records in a database
SQL CAN
UPDATE RECORDS IN A DATABASE
Sql CAN DELETE RECORDS FROM ADATABASE
SQL can
create new database
SQL can
create new tables in a database
SQL can
create stored procedures in a database
SQL can
create views in a database
SQL can set
permissions on tables, procedures, an views
RDBMS
RDBMS stands
for relational database management system.
RDBMS is the
basis for SQL, and for all modern database systems such as MS SQL server, IBM
DB2, ORACLE, MYSQL and microsoft access.
The data in
RDBMS is stored in datbase objects called tables. A table is a collection of
related data entries and it consists of columns and rows.
Every table
is broken up into smaller entities called fields. The fields in the customers
table consist of customerID, customerName, ContactName, , address, city,
postalcode and country. A fieeld is a column in a table that is designed to
maintain specific information about every record in the table.
A record,
also called a row , is each individual entry that exists in a table.
A column is
a vertical entity in a table that contains all information associated ith a
specific field in a table.
INTRODUCTION TO SQL SERVER
Orgaizations
often maintain large amonts of dat, which are generated as a result of
day-to-day operations.
A database:
Is an organized from of such data.
May consist of one or more
related data items colled records.
Is a data collectio to which
different questions can be asked.
For example,
What are the phone numbers and
addresses of the five nearest post
Do we have any books in our
library that deal with health food:
DATA AND
DATABASE
DATA : Data
is raw , unorganized facts that need to be procesed. Data can be something
simple and seemingly random and useless until it is organized.
Example:
71000 – no meaning, unorganized
INFORMATION:
when this data is gahered, analyzed and processed, it yields information.
Example:
71000 postal code of hydrabad sindh.
DATABASE : A
database is an organized collection of data such that its contents can be
easily accessed, managed, and updated.
REAL LIFE
EXAMPLE OF DATBASE: A phone book is a database consisting of name, addresses,
and telphone numbers.
DATA
MANAGEMENT
Data management
deals with managing large amount of information, which involves:
The storage of information
The provision of mechanisms for
the manipulation of information
Providing safety of information
stored under various cercumstances
The two
different approaches of managing data are as follows:
File-based systems
Database systems
FILE-BASED
SYSTEMS
In a
file-based systems data id stored in discrete files and a collection of sucsh
files
Is stored on
a computer.
Rows in the
table were colled records and columns were colled fields.
Data redundancy and
inconsistency
Data isolation
Concurrent access anomalies
Security problems
Integrity problems
Databse systems.
Database
systems evolved in the late 1960s to address common issues in applications
hanling large volumes of daa, which are also data intensive.
At any point
of time, data can be retrieved from the database, added, and searched based on
some criteria in these databases.
Databases
are used to store data in an efficient and organized manner. A database allows
quick and eas management of data.
Data stored
in this form is not permanent. Record in such manual files can only be
maintained for a few months or few years.
ADVANTAGES
OF DATABASE SYSTEMS
The amount of redundancy in the
stored data can be reduced
No more inconsistencies in data
The stored data can be shared
Standards can be set and
followed
Data integrity can be
maintained. (no repetition and null values)
Security of data can be
implemented.
ENTITY :
An entity is a person, place,
thing, object, event, or even a concept, which can be distinctly
Identified.
Each entity has certain
characteristics known as attributes.
For example, the student entit
might include attributes like student
Number, name , and grade. Each
attribute should be named appropriately.
For examples, the entities in a
university are students, faculty members, and
Course.
A grouping of related entities
becomes an entity set. Each entity set is given
A name. the name of the entity
set reflects the contents.
DATABASE MANAGEMENT SYSTEM (DBMS):
a. A
DBMS is a collection of related records and a set of programs that access
And manipulate these
records and enables the user to enter, store, and manage data.
b.
A database is a collection of interrelated data,
and a DBMS is a set of program used to add or modify this data.
c.
DBMS supports one of the four database models.
EXAMPLES :
a.
Computerized library systems
b.
Flight reservation systems
c.
Automated teller machines
d.
Computerized parts inventory systems
User program
Database system
Application program / query
Software to process
Queries / programs
Database
database
DATABASE
MODEL IN SQL SERVER
a.
Databases can be differentiated based on
functions and model of the data.
b.
The analysis and design of data models has been
the basis of the evolution of databases.
c.
Each model has evolved from the previous one.
The commonly used datbase models are as follows:
d.
A data model describes a container for storing
data, and the process of storing and retrieving data from that container.
Flat-file
data model
1.
In this model, the database consists of only one
table or file.
2.
This model is used for simple databases – for
example, to store the roll numbers, names, subjects, and marks of a group of
students.
3.
This model cannot handle very complex data. It
can cause redundancy when data is repeated more than once.
HIERARCHICAL
DATA MODEL
1.
In this model, different records are
inter-related through hierarchical or tree-like structures
2.
A parent record can have several children, but a
child can have only one parent.
3.
To find data stored in this model, the user
needs to know the structure of the tree.
|
COLLEGE
|
|
INFRASTRUCTURE
|
|
STUDENTS
|
|
COURSE
|
|
LAB
|
|
TEORY
|
|
TEACHERS
|
|
DEPARTEMENT
|
NETWORK DATA MODEL:
a.
This model was
developed to overcome the problems of hierarchical model
b.
This model is
similar to the hierarchical data model. It is actually a subset of the network
model.
c.
The set theory of
the network model does not use a single-parent tree hierarchy. It allows a
child to have more than one parent. Thus, the records are physically linked.
|
Departement
student
Course
professor
|
|
unit
|
|
id
|
|
name
|
|
name
|
|
no
|
|
student
|
|
course
|
|
name
|
|
id
|
|
Name
|
|
No
|
The advantage of such a structure are specified as
follows :
Relationships
are easier to implement in the network datbase model than in the hierarchical
model.
This
model enforces database integrity.
This
model achieves sufficient data indeendence.
The disadvantages are specified as follows:
The
database in this model are difficult to design.
The
programmer has to ve familiar with the internal stuctures to access the
database.
RELATIONAL
DATA MODEL
Edgar
frank codd (19 agustus 1923 – 18 april 2003) was an english computer scientis
who, while working for IBM, invented the relational model for database
management in 1969.
In
this relational data model where all data is represented in terms of tuples
(rows), grouped into relations ( tables).
The
term ‘Relation’ is derived from the set theory of mathematics. In the
relational model, unlike the hierarchical and network models, there are no physical links.
All
data is maintained in the form of tables consisting of rows and columns. Data
in two tables is related in the form of tables consisting of rows and columns.
Data in two tables is related through common columns and not physical links.
This
led to the development of what came to be called the relational model database.
Operators
are provided for operating on rows in tables. This model repesents the database
as a collection of relations.
|
employee
|
|
|
|
|
departement
|
|
|
Emp_id
|
Emp_name
|
Address
|
Dept_id
|
|
Dept_id
|
Dept_name
|
|
100
|
Joseph
|
Clinton town
|
10
|
|
10
|
Accounting
|
|
101
|
Rose
|
Fraser town
|
20
|
|
20
|
Quality
|
|
102
|
Mathew
|
Lakeside village
|
10
|
|
30
|
design
|
|
103
|
Stewart
|
Troy
|
30
|
|
|
|
|
104
|
william
|
holand
|
30
|
|
|
|
a.
A row is called a tuple or record.
b.
A column is called an attribute.
c.
The table is called a relation.
d.
Several attributes can belong to the same domain.
|
ATTRIBUTES
|
RELATION
NAME
STUDENT
|
Ssn
|
Home_phone
|
Address
|
Office_phone
|
Age
|
GPA
|
|
|
HENDRI
|
12-15-55
|
5913330
|
KEDUNGREJO
|
03335920002
|
18
|
3.21
|
|
|
BASUKI
|
15-13-65
|
5912345
|
MUNCAR
|
03338450001
|
20
|
2.21
|
|
|
|
|
|
|
|
|
|
RELATIONAL DATABASE MANAGEMENT SYSTEM (RDBMS)
Ø
Relational model is an attempt to simplify
datbase structures.
Ø
An RDBMS is a software program that helps to
create, maintain, and manipulate a relational database.
Ø
A relational database is a database divided into
logical units called tables, where tables are related to one another within the
database.
Ø
Represents all data in the database as simple
row-column tables of data values.
Ø
Tables are related in a relational database,
allowing adequate data to be retrieved in a single query ( although the desired
data may exist in more than one table). Example: SQL Server, MySQL, Oracle is a
RDBMS softwarre.
|
Relationship base on keys
|
|
Order
table order
detail table
|
Mysql server 2008
Example :
Create database sekolah; tanda untuk meng akhiri perentah sql
Use
student;
Create
table student (student_id int,
student_name varchar (50), nis int, klas varchar(50);
Select * from
student; asterik merupakan pilihan semua.
Mengisi data.
Insert into student values
(1,’basuki’,12,’10th’);
Insert
into student values (2,’anwar’,12,’11th’);
Insert
into student values (3,’bambang’,12,’12th’);
Or insert into student
(student_id,student_name) values (4,’sigit’)
Try to app
sqlserver.
SQL Constrants.
SQL Conxtraints are used to specify rules for the
data in a table.
Constraints are used to limit the type of data that
can go into a table.
This enseres the accuracy and reliability of the
data in the table. If there is any violation between the constraint and the
data action, the action is aborted.
Constraints can be column level or table level.
Column level constraints apply to a column, and table level constraints apply
to the whole table.
The following constraints are commonly used in SQL:
NOT NULL – ensures that a column cannot have a NULL
value.
UNIQUE – ensures that all values in a column are
different.
PRIMARY KEY -
a combination of a NOT NULL and UNIQUE.
Uniquely identifies each row in a table.
FOREIGN KEY -
uniquely identifies a row/record in another table.
CHECK – ensures that all values in a column
satisfies a specific condition.
DEFAULT – Sets a default value for a column when no
value is specified.
INDEX – Use to create and retrieve data from the datbase
very quickly.
sekian dulu ... tunggu kelanjutan definisi triger dan CURD
BASUKI BUDIJANI
Komentar
Posting Komentar