4. Propagation Constraint
What happens if we delete a Boat from our Boat Hire database?
There are lots of Rental records that reference it. What happens to
them?
5. Table with Propagation Constraint
Create Table Rental
(BoatID number NOT NULL,
CustomerID number NOT NULL,
RentalStartDate date NOT NULL,
RentalEndDate date NOT NULL,
Primary Key (BoatID, CustomerID, RentalStartDate)
Foreign Key (CustomerID) REFERENCES Customer(CustomerID),
Foreign Key (BoatID) REFERENCES Boat (BoatID)
On delete no action
On update cascade);
7. Domain Constraints
Boat Type could be enforced as...
a check constraint
separate domain using Create Domain statement
as a foreign key to another table
8. Check Constraint
Create Table Boat
(BoatID number NOT NULL,
BoatName varchar (30) NOT NULL,
BoatType varchar (20),
Primary Key (BoatID)
Check (BoatType in ‘Yacht’,’Cruiser’,’Rower’));
9. As a Separate Domain
Create Domain BoatType As varchar(20)
Default ‘Yacht’
Check (Value in (‘Yacht’,’Cruiser’,’Rower’));
The table’Boat’ will set the BoatType attribute as this domain
BoatType.
10. As a Separate Table
Create Table BoatType
(BoatTypeCode Varchar(3),
BoatTypeDescription Varchar(20)
Primary Key (BoatTypeCode));
With the corresponding Foreign Key in Boat
Create Table Boat
(BoatID number NOT NULL,
BoatName varchar (30) NOT NULL,
BoatTypeCode varchar (3),
Primary Key (BoatID)
Foreign Key (BoatTypeCode) References BoatType;
11. Table Constraints
Create Table Rental
(BoatID number NOT NULL,
CustomerID number NOT NULL,
RentalStartDate date NOT NULL,
RentalEndDate date NOT NULL
Constraint MaximumRentals
Check(Not Exists(Select BoatID
From Rentals
Group By BoatID
Having Count(*) >10)),
Primary Key (BoatID, CustomerID, RentalStartDate)
Foreign Key (CustomerID) REFERENCES Customer(Custo
Foreign Key (BoatID) REFERENCES Boat (BoatID)
On delete no action
On update cascade);
This constraint is checked if there is any
modification to a row, regardless the value of the
column changed or not.
In column constraint the condition is checked
when the value of the column changed.
Eg Domain Constraints
12. Inserting Data
The basic SQL feature for inserting multiple rows:
INSERT INTO ''TABLE'' (''column-name'', [''column-name', ...])
VALUES (''1st row value a'',"1st row value b"),
(''2nd row value a', "2nd row value b"),
...
Example
Insert into boats (boatID, boatName)
Values (1,'Esmerelda'),
(2,'Missy'),
(3,'Lord George');
13. Data Loading Tools
Bulk insert in SQL server
http://sqlserver2000.databases.aspfaq.com/how-do-i-load-
text-or-csv-file-data-into-sql-server.html
Oracle SQL loader
http://oreilly.com/catalog/orsqlloader/chapter/ch01.html
My-SQL uses something called 'Bulk Insert'
http://mysql.bigresource.com/Bulk-insert-from-text-files-
dDPRzHYo.html#2t6P0D5I
15. Oracle
For many years, Oracle was the largest market share AND largest by value.
It was challenged recently by MySQL.
16. Support for Languages
Java Programming – allowing sophisticated manipulation
of data using the logic of a programming language
XML – allowing development of own tags so capable of
transmitting data in almost any format
20. Logical Structure of Oracle
Tables spaces – logical storage units that contain the other objects,
which have memory divided into blocks, extents, and segments.
Database schemas contain or own the objects like tables.
Definition of users
21. Physical Structure of Oracle
Datafiles
Database datafiles are physical files stored on disk. These files are used to store data on disk.
Database datafiles are only written to by the DBWR processes
Redo logs
Like a tape recorder that records every change in the Oracle database. As changes occur, they
are regularly recorded in the online redo logs, just like you might record a movie on your VCR.
Control files
The Control File of the database is a binary file that contains a great deal of database
information. The control file contains the database name, data about the database log files.
Oracle cannot function without valid control files.
22. Oracle Instance
Contains all the processes and memory areas.
A database instance is a set of memory structures that manage database files
The instance manages its associated data and serves the users of the database.
Also contains...
23. Oracle Instance
- System Global Area: When an instance is started, Oracle Database allocates a
memory area called the SGA.
- Program Global Area: A PGA is a memory region that contains data and control
information for a server process. It is no shared memory created by Oracle
Database when a server process is started
- User Processes: User roles and user management
24. References
Benyon-Davis, P. (2003). Database Systems, 3rd edition. Palgrave Macmillan.
Chapter 12.
Connolly, T. & Begg, C. (2004). Database Systems: A Practical Approach to
Design, Implementation, and Management, 4th Edition. Addison Wesley.
Chapters 8 & 17.
Try to describe the client/server architecture of oracle. In the Oracle Database environment, the database application and the database are separated into a client/server architecture: The client runs the database application, for example, SQL*Plus or a Visual Basic data entry program, that accesses database information and interacts with a user. Try to follow this link as well https://www.wiziq.com/tutorial/167572-CLIENT-SERVER-ARCHITECTURE-IN-DATABASE