Vous êtes sur la page 1sur 7

Session Date : 08 Oktober 2019

Semester : 3
Subject : Basisdata
Topic : Creating Databases and Tables
Activity :  Creating and managing Databases using Transact-SQL
 Creating and managing Tables using Transact-SQL
 Inserting data into tables
Duration : 100 minutes
Rules Individual
Deliverable : Softcopy
Place to deliver : http://ecourse.del.ac.id/
Objective  Able to create database and tables by using T-SQL query
statement.
 Able to manage database by performing the activities:
managing growth of database files and adding database files.
Lecturer : Verawaty Situmorang

Background
In this practical, you will create database and tables for the Tennis Database. For the ease of
practical and for uniformity, you will create database and tables by following database diagram
and tables’ specification given in this practical. The CDM is given by Figure 1 below:

Figure 1 Database Diagram for Tennis Database

The meaning of the contents of the tables:

BASDAT/CreatingDatabaseAndTables 1 of 7
Table:
Column:
PLAYERS
PLAYERNO Unique player number assigned by the club
NAME Surname of the players, without initials
INITIALS Initials of the players. No full stops or
spaces are used.
BIRTH_DATE Date on which the player was born.
SEX Sex of the player: M(Male) or F(Female.
JOINED Year in which the player joined the club.
This value cannot be smaller than 1970, the
year in which the club was founded.
STREET Name of the street on which the players
lives.
HOUSENO Number of house.
POSTCODE Post code.
TOWN Town or city in which player lives.
PHONENO Area code followed by a hyphen and then
the subscriber’s number.
LEAGUENO League number assigned by the league; a
league number is unique.

TEAMS
TEAMNO Unique team number assigned by the club.
PLAYERNO Player number of the player who captains the
team. In principle, a player may captain several
teams.
DIVISION Division in which the league has placed the
team.

MATCHES
MATCHNO Unique matches number assigned by the club.
TEAMNO Number of the team
PLAYERNO Number of the player
WON Number of sets that the player won in the
match
LOST Number of sets that the player lost in the match

PENALTIES

BASDAT/CreatingDatabaseAndTables 2 of 7
PAYMENTNO Unique number for each penalty the club has
paid. This number is assigned by the club
PLAYERNO Number of player who has incurred the penalty
PAYMENT_DATE Date on which the penalty was paid. The year
of this date should not be earlier than 1970, the
year in which the club was founded.
AMOUNT Amount in dollars incurred for the penalty.

COMMITTEE_MEMBERS
PLAYERNO The number of the player
BEGIN_DATE Date on which the player became an active
member of committee. This date should not be
earlier than January 1, 1990, because this is the
date on which the club started to record this
data.
END_DATE Date on which the player resigned his position
in committee. This date should not be earlier
than the BEGIN_DATE but can be absent.
POSITION Name of the position.

Tables spesifications are given as follows:

Table 1 : PLAYERS
Attribute Type(Size) Null
Name Allowed
PLAYERNO INT N
NAME CHAR(15) N
INITIALS CHAR(3) N
BIRTH_DATE DATE Y
SEX CHAR(1) N
JOINED SMALLINT N
STREET VARCHAR(30) N
HOUSENO CHAR(4) Y
POSTCODE CHAR(6) Y
TOWN VARCHAR(30) N
PHONENO CHAR(13) Y
LEAGUENO CHAR(4) Y
Table 2 : TEAMS

Type(Size) Null Allowed


TEAMNO INTEGER N
PLAYERNO INTEGER N
DIVISION CHAR(6) N

BASDAT/CreatingDatabaseAndTables 3 of 7
Table 3 : MATCHES
Attribute Type(Size) Null
Name Allowed
MATCHNO INTEGER N
TEAMNO INTEGER N
PLAYERNO INTEGER N
WON SMALLINT N
LOST SMALLINT N

Table 4 : PENALTIES
Attribute Name Type(Size) Null
Allowed
PAYMENTNO INTEGER N
PLAYERNO INTEGER N
PAYMENT_DATE DATE N
AMOUNT DECIMAL(7,2) N

Table 5 : COMMITTEE_MEMBERS
Attribute Type(Size) Null Allowed
Name
PLAYERNO INTEGER N
BEGIN_DATE DATE N
END_DATE DATE Y
POSITION CHAR(20) Y

Exercise 1. Creating the Tennis Database


Task-1
Write and execute a statement that creates a Tennis database by using the parameters
specification given in Table below. Note that for value of path files (Operating System Data File
Name and Operating System Log File Name),you can change the Path of those files, but please
do keep the Size Parameter the same as given in the table in order to Save Disk Space.

Parameter Value
Database Name TennisDB
Database Logical File Name(Primary) TennisDBPrimary
Operating System Data File Name D:\2018-2019\SBD\03. Materi
Praktikum\Week
02\s02\TennisDB.mdf
Data File Initial Size 10 MB
Data File Maximum Size 20 MB
Data File Growth Increment 20 %
Database Logical File TennisDBSecondary

BASDAT/CreatingDatabaseAndTables 4 of 7
Name(Secondary)
Operating System Data File Name D:\2018-2019\SBD\03. Materi
Praktikum\Week
02\s02\TennisDB.ndf
Data File Initial Size 5 MB
Data File Maximum Size 10 MB
Data File Growth Increment 20 %
Log Logical File Name(Primary) TennisDBLog
Operating System Data File Name D:\2018-2019\SBD\03. Materi
Praktikum\Week
02\s02\TennisDB.ldf
Data File Initial Size 30 MB
Data File Maximum Size 50 MB
Data File Growth Increment 20 %

Task-2
After creating the Tennis Database, view the Information (Metadata) of database to verify that
the database was created.

Exercise 2. Managing the Growth Files


Task-1
Write and execute a statement to increase the maximum size of the TennisDBLog to 60
megabytes (60 MB)

Task-2
After modifying/ Altering the Tennis Database view the Information (Metadata) of Tennis
Database to verify that the changer are applied.

Task-3
Repeat the Task-1 to modify the size of database and make it as previous. What do you find?

Exercise 3. Adding Database Files


Task-1
Add a Secondary Data file to the Tennis Database by using the parameters specification given in
Table 7 below.

Parameter Value
Database Logical File Name(Secondary) TennisDBSecondary2
Operating System Data File Name
Data File Initial Size 5 MB
Data File Maximum Size 10 MB
Data File Growth Increment 20 %

Task-2

BASDAT/CreatingDatabaseAndTables 5 of 7
Creates a file group to the Tennis Database and adds two 5 MB secondary files to the file group.
The name of the file group is TennisGroup. The names of the two secondary files are
TennisDB_1 and TennisDB_2. The maximum size for the each file is 10 MB and the growth
incremental is 1 MB.

Task-3
After applying the file group on Tennis Database, remove TennisDB_2 file from the database.

BASDAT/CreatingDatabaseAndTables 6 of 7
Exercise 4. Create Tables and Inserting Data
Task – 1
Create all President Tables that give in above Conceptual Data Model. Follow tables’
specification given in Table 1 until Table 5.

Task -2
Insert data to all tables.

Deliverable
Database TennisDB tersebut kalian simpan dalam file berformat .sql
Filename: NIM_NAMA.sql

BASDAT/CreatingDatabaseAndTables 7 of 7

Vous aimerez peut-être aussi