Database Management System Overview
Database Management System Overview
Overview of Database
A Database is a collection of related data organized in a way that data can be easily accessed,
managed and updated. Any piece of information can be a data, for example name of your
school. Database is actually a place where related piece of information is stored and various
operations can be performed on it.
DBMS
A DBMS is a software that allows creation, definition and manipulation of database. Dbms is
actually a tool used to perform any kind of operation on data in database. Dbms also provides
protection and security to database. It maintains data consistency in case of multiple users.
Here are some examples of popular dbms, MySql, Oracle, Sybase, Microsoft Access and IBM
DB2 etc.
Users: Users may be of various type such as DB administrator, System developer and End
users.
Database application : Database application may be Personal, Departmental, Enterprise
and Internal
DBMS: Software that allow users to define, create and manages database access, Ex: MySql,
Oracle etc.
Database: Collection of logical data.
Functions of DBMS
Advantages of DBMS
Disadvantages of DBMS
Complexity
Costly
Large in size
Database Architecture
Database architecture is logically divided into two types.
Two-tier Client / Server architecture is used for User Interface program and Application
Programs that runs on client side. An interface called ODBC(Open Database Connectivity)
provides an API that allow client side program to call the dbms. Most DBMS vendors provide
ODBC drivers. A client program may connect to several DBMS's. In this architecture some
variation of client is also possible for example in some DBMS's more functionality is
transferred to the client including data dictionary, optimization etc. Such clients are called
Data server.
Three-tier Client / Server database architecture is commonly used architecture for web
applications. Intermediate layer called Application server or Web Server stores the web
connectivity software and the business logic(constraints) part of application used to access the
right amount of data from the database server. This layer acts like medium for sending partially
processed data between the database server and the client.
Database Model
A Database model defines the logical design of data. The model describes the relationships
between different parts of the data. Historically, in database design, three models are
commonly used. They are,
Hierarchical Model
Network Model
Relational Model
Hierarchical Model
In this model each entity has only one parent but can have several children. At the top of
hierarchy there is only one entity which is called Root.
Network Model
In the network model, entities are organized in a graph, in which some entities can be accessed
through several path
Relational Model
In this model, data is organized in two-dimensional tables called relations. The tables or
relation are related to each other.
Codd's Rule
E.F Codd was a Computer Scientist who invented Relational model for Database management.
Based on relational model, Relation database was created. Codd proposed 13 rules popularly
known as Codd's 12 rules to test DBMS's concept against his relational model. Codd's rule
actually define what quality a DBMS requires in order to become a Relational Database
Management System(RDBMS). Till now, there is hardly any commercial product that follows all
the 13 Codd's rules. Even Oracle follows only eight and half out(8.5) of 13. The Codd's 12 rules
are as follows.
Rule zero
This rule states that for a system to qualify as an RDBMS, it must be able to manage database
entirely through the relational capabilities.
Rule 1 : Information rule
All information(including metadata) is to be represented as stored data in cells of tables. The
rows and columns have to be strictly unordered.
Rule 2 : Guaranteed Access
Each unique piece of data(atomic value) should be accessible by : Table Name + primary
key(Row) + Attribute(column).
What is Table ?
In Relational database, a table is a collection of data elements organized in terms of rows and
columns. A table is also considered as convenient representation of relations. But a table can
have duplicate tuples while a true relation cannot have duplicate tuples. Table is the most
simplest form of data storage. Below is an example of Employee table.
Name Age Salary
ID
1 Adam 34 13000
2 Alex 28 15000
3 Stuart 20 18000
4 Ross 42 19020
What is a Record ?
A single entry in a table is called a Record or Row. A Record in a table represents set of related
data. For example, the above Employee table has 4 records. Following is an example of single
record.
1 Adam 34 13000
What is Field ?
A table consists of several records(row), each record can be broken into several smaller entities
known as Fields. The above Employee table consist of four fields, ID, Name, Age and Salary.
What is a Column ?
In Relational table, a column is a set of value of a particular type. The term Attribute is also
used to represent a column. For example, in Employee table, Name is a column that represent
names of employee.
Name
Adam
Alex
Stuart
Ross
Database Keys
Keys are very important part of Relational database. They are used to establish and identify
relation between tables. They also ensure that each record within a table can be uniquely
identified by combination of one or more fields within a table.
Super Key
Super Key is defined as a set of attributes within a table that uniquely identifies each record
within a table. Super Key is a superset of Candidate key.
Candidate Key
Candidate keys are defined as the set of fields from which primary key can be selected. It is an
attribute or set of attribute that can act as a primary key for a table to uniquely identify each
record in that table.
Primary Key
Primary key is a candidate key that is most appropriate to become main key of the table. It is a
key that uniquely identify each record in a table.
Composite Key
Key that consist of two or more attributes that uniquely identify an entity occurance is
called Composite key. But any attribute that makes up the Composite key is not a simple key in
its own.
Normalization of Database
Database Normalization is a technique of organizing the data in the database. Normalization is
a systematic approach of decomposing tables to eliminate data redundancy and undesirable
characteristics like Insertion, Update and Deletion Anamolies. It is a multi-step process that
puts data into tabular form by removing duplicated data from the relation tables.
Normalization is used for mainly two purpose,
Eliminating redundant(useless) data.
Ensuring data dependencies make sense i.e data is logically stored.
Updation Anamoly : To update address of a student who occurs twice or more than twice
in a table, we will have to update S_Address column in all the rows, else data will become
inconsistent.
Insertion Anamoly : Suppose for a new admission, we have a Student id(S_id), name and
address of a student but if student has not opted for any subjects yet then we have to
insert NULL there, leading to Insertion Anamoly.
Deletion Anamoly : If (S_id) 401 has only one subject and temporarily he drops it, when we
delete that row, entire student record will be deleted along with it.
Normalization Rule
Normalization rule are divided into following normal form.
1. First Normal Form
2. Second Normal Form
3. Third Normal Form
4. BCNF
In Subject Table the candidate key will be {Student, Subject} column. Now, both the above
tables qualifies for Second Normal Form and will never suffer from Update Anomalies. Although
there are a few complex cases in which table in Second Normal Form suffers Update Anomalies,
and to handle those scenarios Third Normal Form is there.
E-R Diagram
ER-Diagram is a visual representation of data that describes how data is related to each other.
Symbols and Notations
Weak Entity
Weak entity is an entity that depends on another entity. Weak entity doen't have key attribute
of their own. Double rectangle represents weak entity.
2) Attribute
An Attribute describes a property or characterstic of an entity. For example, Name, Age,
Address etc can be attributes of a Student. An attribute is represented using eclipse.
Key Attribute
Key attribute represents the main characteristic of an Entity. It is used to represent Primary key.
Ellipse with underlying lines represent Key Attribute.
Composite Attribute
An attribute can also have their own attributes. These attributes are known
as Composite attribute.
3) Relationship
A Relationship describes relations between entities. Relationship is represented using
diamonds.
Binary Relationship
Recursive Relationship
Ternary Relationship
Binary Relationship
Binary Relationship means relation between two Entities. This is further divided into three
types.
The above example describes that one student can enroll only for one course and a course
will also have only one Student. This is not what you will usually see in relationship.
2. One to Many : It reflects business rule that one entity is associated with many number of
same entity. The example for this relation might sound a little weird, but this menas that
one student can enroll to many courses, but one course will have one Student.
The arrows in the diagram describes that one student can enroll for only one course.
3. Many to One : It reflects business rule that many entities can be associated with just one
entity. For example, Student enrolls for only one Course but a Course can have many
Students.
4. Many to Many :
The above diagram represents that many students can enroll for more than one courses.
Recursive Relationship
When an Entity is related with itself it is known as Recursive Relationship.
Ternary Relationship
Relationship of degree three is called Ternary relationship.
Generalization
Generalization is a bottom-up approach in which two lower level entities combine to form a
higher level entity. In generalization, the higher level entity can also combine with other lower
level entity to make further higher level entity.
Specialization
Specialization is opposite to Generalization. It is a top-down approach in which one higher level
entity can be broken down into two lower level entity. In specialization, some higher level
entities may not have lower-level entity sets at all.
Aggregration
Aggregration is a process when relation between two entity is treated as a single entity. Here
the relation between Center and Course, is acting as an Entity in relation with Visitor.
SQL tutorial gives unique learning on Structured Query Language and it helps to make practice
on SQL commands which provides immediate results. SQL is a language of database, it includes
database creation, deletion, fetching rows and modifying rows etc.
SQL is an ANSI (American National Standards Institute) standard but there are many different
versions of the SQL language.
What is SQL?
SQL is Structured Query Language, which is a computer language for storing, manipulating and
retrieving data stored in relational database.
SQL is the standard language for Relation Database System. All relational database
management systems like MySQL, MS Access, Oracle, Sybase, Informix, postgres and SQL
Server use SQL as standard database language.
Why SQL?
Allows users to access data in relational database management systems.
Allows users to describe the data.
Allows users to define the data in database and manipulate that data.
Allows to embed within other languages using SQL modules, libraries & pre-compilers.
Allows users to create and drop databases and tables.
Allows users to create view, stored procedure, functions in a database.
Allows users to set permissions on tables, procedures, and views
History:
1970 -- Dr. Edgar F. "Ted" Codd of IBM is known as the father of relational databases. He
described a relational model for databases.
1974 -- Structured Query Language appeared.
1978 -- IBM worked to develop Codd's ideas and released a product named System/R.
1986 -- IBM developed the first prototype of relational database and standardized by ANSI. The
first relational database was released by Relational Software and its later becoming Oracle.
SQL Process:
When you are executing an SQL command for any RDBMS, the system determines the best
way to carry out your request and SQL engine figures out how to interpret the task.
There are various components included in the process. These components are Query
Dispatcher, Optimization Engines, Classic Query Engine and SQL Query Engine, etc. Classic
query engine handles all non-SQL queries but SQL query engine won't handle logical files.
The amount of information available to us is literally exploding, and the value of data as an
organizational asset is widely recognized. To get the most out of their large and complex
datasets, users require tools that simplify the tasks of managing the data and extracting useful
information in a timely fashion. Otherwise, data can become a liability, with the cost of
acquiring it and managing it far exceeding the value derived from it. A database management
system, or DBMS, is software designed to assist in maintaining and utilizing large collections of
data. The collection of data, usually referred to as database, contains information relevant to an
enterprise. The primary goal of a DBMS is to provide a way to store and retrieve database
information that is both convenient and efficient. A data model is a collection of high-level data
description constructs that hide many low-level storage details. A DBMS allows a user to define
the data to be stored in terms of a data model. Most database management systems today are
based on the relational data model. A relational database consists of a collection of tables
(mathematical concept of relation). A row in a table represents a relationship among a set of
values. Informally, a table is an entity set, and a row is an entity. The relational model is very
simple and elegant: a database is a collection of one or more relations, where each relation is a
table with rows and columns. This simple tabular representation enables even novice users to
understand the contents of a database, and it permits the use of simple, high-level languages to
query the data.
SQL stands for “Structured Query Language” and can be pronounced as “SQL” or “sequel –
(Structured English Query Language)”. It is a query language used for accessing and modifying
information in the database. It has become a Standard Universal Language used by most of the
relational database management systems (RDBMS). SQL is tied very closely to the relational
model. Few of the SQL commands used in SQL programming are SELECT Statement, UPDATE
Statement, INSERT INTO Statement, DELETE Statement, WHERE Clause, ORDER BY Clause,
GROUP BY Clause, ORDER Clause, Joins, Views, GROUP Functions, Indexes etc. In a simple
manner, SQL is a non-procedural, English-like language that processes data in groups of records
rather than one record at a time. Few functions of SQL are:
store data
modify data
retrieve data
delete data
create tables and other database objects
Components of SQL
Create command
Create is a DDL command used to create a table or a database.
Creating a Database
To create a database in RDBMS, create command is uses. Following is the Syntax,
Create database database-name;
Creating a Table
create command is also used to create a table. We can specify names and datatypes of various
columns along. Following is the Syntax,
create table table-name
{
column-name1 datatype1,
column-name2 datatype2,
column-name3 datatype3,
column-name4 datatype4
};
create table command will tell the database system to create a new table with given table
name and column information.
The above command will create a new table Student in database system with 3 columns,
namely id, name and age.
alter command
alter command is used for alteration of table structures. There are various uses
of alter command, such as,
to add a column to existing table
to rename any existing column
to change datatype of any column or to modify its size.
alter is also used to drop a column.
The above command will add three new columns to the Student table
The above command will add a new column with default value to the Student table
The above command will modify address column of the Student table
To Rename a column
Using alter command you can rename an existing column. Following is the Syntax,
alter table table-name rename old-column-name to column-name;
To Drop a Column
alter command is also used to drop columns also. Following is the Syntax,
alter table table-name drop(column-name);
The above command will drop address column from the Student table
truncate command removes all records from a table. But this command will not destroy
the table's structure. When we apply truncate command on a table its Primary key is
initialized. Following is its Syntax,
truncate table table-name
The above query will delete all the records of Student table.
truncate command is different from delete command. delete command will delete all the rows
from a table whereas truncate command re-initializes a table(like a newly created table).
For eg. If you have a table with 10 rows and an auto_increment primary key, if you
use delete command to delete all the rows, it will delete all the rows, but will not initialize the
primary key, hence if you will insert any row after using delete command, the auto_increment
primary key will start from 11. But in case of truncatecommand, primary key is re-initialized.
drop command
drop query completely removes a table from database. This command will also destroy the
table structure. Following is its Syntax,
drop table table-name
The above query will delete the Student table completely. It can also be used on Databases.
For Example, to drop a database,
drop database Test;
The above query will drop a database named Test from the system.
rename query
DML command
Data Manipulation Language (DML) statements are used for managing data in database. DML
commands are not auto-committed. It means changes made by DML command are not
permanent to database, it can be rolled back.
1) INSERT command
Insert command is used to insert data into a table. Following is its general syntax,
INSERT into table-name values(data1,data2,..)
Or,
INSERT into Student values(102,'Alex',null);
The above command will insert only two column value other column is set to null.
S_id S_Name age
101 Adam 15
102 Alex
Also, if you run the below query, it will insert default value into the age column, whatever the
default value may be.
INSERT into Student values(103,'Chris')
2) UPDATE command
Update command is used to update a row of a table. Following is its general syntax,
UPDATE table-name set column-name = value where condition;
3) Delete command
Delete command is used to delete data from a table. Delete command can also be used with
condition to delete a particular row. Following is its general syntax,
DELETE from table-name;
The above command will delete all the records from Student table.
The above command will delete the record where s_id is 103 from Student table.
S_id S_Name age
101 Adam 15
102 Alex 18
TCL command
Transaction Control Language(TCL) commands are used to manage transactions in database.
These are used to manage the changes made by DML statements. It also allows statements to
be grouped together into logical transactions.
Commit command
Rollback command
This command restores the database to last commited state. It is also use with savepoint
command to jump to a savepoint in a transaction.
Savepoint command
savepoint command is used to temporarily save a transaction so that you can rollback to that
point whenever necessary.
DCL command
Data Control Language(DCL) is used to control privilege in Database. To perform any operation
in the database, such as for creating tables, sequences or views we need privileges. Privileges
are of two types,
System : creating session, table etc are all types of system privilege.
Object : any command or query to work on tables comes under object privilege.
WHERE clause
Where clause is used to specify condition while retrieving data from table. Where clause is used
mostly with Select, Update and Delete query. If condition specified by where clause is true then
only the result from table is returned.
Syntax for WHERE clause
SELECT column-name1,
column-name2,
column-name3,
column-nameN
from table-name WHERE [condition];
SELECT Query
Select query is used to retrieve data from a tables. It is the most used SQL query. We can
retrieve complete tables, or partial by mentioning conditions using WHERE clause.
Syntax of SELECT Query
SELECT column-name1, column-name2, column-name3, column-nameN from table-name;
Example for SELECT Query
The above query will fetch information of s_id, s_name and age column from Student table
S_id S_Name age
101 Adam 15
102 Alex 18
103 Abhi 17
104 Ankit 22
The above query will show all the records of Student table, that means it will show complete
Student table as result.
S_id S_Name age address
101 Adam 15 Noida
102 Alex 18 Delhi
103 Abhi 17 Rohtak
104 Ankit 22 Panipat
The above command will display a new column in the result, showing 3000 added into existing
salaries of the employees.
eid Name salary+3000
101 Adam 8000
102 Ricky 11000
103 Abhi 13000
104 Rohan 8000
Like clause
Like clause is used as condition in SQL query. Like clause compares data with an expression
using wildcard operators. It is used to find similar data from the table.
Wildcard operators
There are two wildcard operators that are used in like clause.
Percent sign % : represents zero, one or more than one character.
Underscore sign _ : represents only one character.
The above query will return all records where s_name starts with character 'A'.
s_id s_Name age
101 Adam 15
102 Alex 18
103 Abhi 17
Example
SELECT * from Student where s_name like '_d%';
The above query will return all records from Student table where s_name contain 'd' as second
character.
s_id s_Name age
101 Adam 15
Example
SELECT * from Student where s_name like '%x';
The above query will return all records from Student table where s_name contain 'x' as last
character.
s_id s_Name age
102 Alex 18
Order By Clause
Order by clause is used with Select statement for arranging retrieved data in sorted order.
The Order by clause by default sort data in ascending order. To sort data in descending
order DESC keyword is used with Order by clause.
Syntax of Order By
SELECT column-list|* from table-name order by asc|desc;
Example using Order by
The above query will return result in ascending order of the salary.
eid name age salary
403 Rohan 34 6000
402 Shane 29 8000
405 Tiger 35 8000
401 Anu 22 9000
404 Scott 44 10000
The above query will return result in descending order of the salary.
eid name age salary
404 Scott 44 10000
401 Anu 22 9000
405 Tiger 35 8000
402 Shane 29 8000
403 Rohan 34 6000
Group By Clause
Group by clause is used to group the results of a SELECT query based on one or more columns.
It is also used with SQL functions to group the result from one or more tables.
HAVING Clause
having clause is used with SQL Queries to give more precise condition for a statement. It is used
to mention condition in Group based SQL functions, just like WHERE clause.
Distinct keyword
The distinct keyword is used with Select statement to retrieve unique values from the
table. Distinctremoves all the duplicate records while retrieving from database.
Syntax for DISTINCT Keyword
SELECT distinct column-name from table-name;
Example
The above query will return only the unique salary from Emp table
salary
5000
8000
10000
AND & OR operator
AND and OR operators are used with Where clause to make more precise conditions for
fetching data from database by combining more than one condition together.
AND operator
The above query will return records where salary is less than 10000 and age greater than 25.
eid name age salary
402 Shane 29 8000
405 Tiger 35 9000
OR operator
OR operator is also used to combine multiple conditions with Where clause. The only difference
between AND and OR is their behaviour. When we use AND to combine two or more than two
conditions, records satisfying all the condition will be in the result. But in case of OR, atleast one
condition from the conditions specified must be satisfied by any record to be in the result.
Example of OR
The above query will return records where either salary is greater than 10000 or age greater
than 25.
402 Shane 29 8000
403 Rohan 34 12000
404 Scott 44 10000
405 Tiger 35 9000
The BETWEEN operator selects values within a range. The values can be numbers, text, or
dates.
The following SQL statement selects all products with a price BETWEEN 10 and 20:
Example
SELECT * FROM Products
WHERE Price BETWEEN 10 AND 20;
NOT BETWEEN Operator Example
To display the products outside the range of the previous example, use NOT BETWEEN:
Example
SELECT * FROM Products
WHERE Price NOT BETWEEN 10 AND 20;
The IN Operator
SQL IN Syntax
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...);
IN Operator Example
The following SQL statement selects all customers with a City of "Paris" or "London":
Example
SELECT * FROM Customers
WHERE City IN ('Paris','London');
Aggregate Functions:
SQL aggregate functions return a single value, calculated from values in a column.
SQL scalar functions return a single value, based on the input value.
The following SQL statement gets the average value of the "Price" column from the "Products"
table:
Example
SELECT AVG(Price) AS PriceAverage FROM Products;
The COUNT() function returns the number of rows that matches a specified criteria.
The COUNT(column_name) function returns the number of values (NULL values will not be
counted) of the specified column:
The COUNT(DISTINCT column_name) function returns the number of distinct values of the
specified column:
Note: COUNT(DISTINCT) works with ORACLE and Microsoft SQL Server, but not with Microsoft
Access.
Demo Database
The following SQL statement counts the number of orders from "CustomerID"=7 from the
"Orders" table:
Example
SELECT COUNT(CustomerID) AS OrdersFromCustomerID7 FROM Orders
WHERE CustomerID=7;
The following SQL statement counts the total number of orders in the "Orders" table:
Example
SELECT COUNT(*) AS NumberOfOrders FROM Orders;
The following SQL statement counts the number of unique customers in the "Orders" table:
Example
SELECT COUNT(DISTINCT CustomerID) AS NumberOfCustomers FROM Orders;
The FIRST() Function
The FIRST() function returns the first value of the selected column.
The following SQL statement selects the first value of the "CustomerName" column from the
"Customers" table:
Example
SELECT FIRST(CustomerName) AS FirstCustomer FROM Customers;
The LAST() function returns the last value of the selected column.
SQL LAST() Syntax
SELECT LAST(column_name) FROM table_name;
The following SQL statement selects the last value of the "CustomerName" column from the
"Customers" table:
Example
SELECT LAST(CustomerName) AS LastCustomer FROM Customers;
The MAX() function returns the largest value of the selected column.
The following SQL statement gets the largest value of the "Price" column from the "Products"
table:
Example
SELECT MAX(Price) AS HighestPrice FROM Products;
The MIN() function returns the smallest value of the selected column.
The following SQL statement gets the smallest value of the "Price" column from the "Products"
table:
Example
SELECT MIN(Price) AS SmallestOrderPrice FROM Products;
The following SQL statement finds the sum of all the "Quantity" fields for the "OrderDetails"
table:
Example
SELECT SUM(Quantity) AS TotalItemsOrdered FROM OrderDetails;
The UCASE() Function
The following SQL statement selects the "CustomerName" and "City" columns from the
"Customers" table, and converts the "CustomerName" column to uppercase:
Example
SELECT UCASE(CustomerName) AS Customer, City
FROM Customers;
The following SQL statement selects the "CustomerName" and "City" columns from the
"Customers" table, and converts the "CustomerName" column to lowercase:
Example
SELECT LCASE(CustomerName) AS Customer, City
FROM Customers;
The LEN() function returns the length of the value in a text field.
The following SQL statement selects the "CustomerName" and the length of the values in the
"Address" column from the "Customers" table:
Example
SELECT CustomerName,LEN(Address) as LengthOfAddress
FROM Customers;
The ROUND() function is used to round a numeric field to the number of decimals specified.
The following SQL statement selects the product name and rounds the price in the "Products"
table:
Example
SELECT ProductName, ROUND(Price,0) AS RoundedPrice
FROM Products;
The NOW() function returns the current system date and time.
The following SQL statement selects the product name, and price for today from the "Products"
table:
Example
SELECT ProductName, Price, Now() AS PerDate
FROM Products;
SQL Constraints
SQl Constraints are rules used to limit the type of data that can go into a table, to maintain the
accuracy and integrity of the data inside table.
Constraints can be divided into following two types,
Constraints are used to make sure that the integrity of data is maintained in the database.
Following are the most used constraints that can be applied to a table.
NOT NULL
UNIQUE
PRIMARY KEY
FOREIGN KEY
CHECK
DEFAULT
In Customer_Detail table, c_id is the primary key which is set as foreign key
in Order_Detail table. The value that is entered in c_id which is set as foreign key
in Order_Detail table must be present in Customer_Detailtable where it is set as primary key.
This prevents invalid data to be inserted into c_id column of Order_Detailtable.
Example using FOREIGN KEY constraint at Table Level
CREATE table Order_Detail(order_id int PRIMARY KEY,
order_name varchar(60) NOT NULL,
c_id int FOREIGN KEY REFERENCES Customer_Detail(c_id));
In this query, c_id in table Order_Detail is made as foriegn key, which is a reference of c_id
column of Customer_Detail.
On Delete Cascade : This will remove the record from child table, if that value of foriegn key
is deleted from the main table.
On Delete Null : This will set all the values in that record of child table as NULL, for which
the value of foriegn key is deleted from the main table.
If we don't use any of the above, then we cannot delete data from the main table for
which data in child table exists. We will get an error if we try to do so.
CHECK Constraint
CHECK constraint is used to restrict the value of a column between a range. It performs check
on the values, before storing them into the database. Its like condition checking before saving
data into a column.
Example using CHECK constraint at Table Level
create table Student(s_id int NOT NULL CHECK(s_id > 0),
Name varchar(60) NOT NULL,
Age int);
The above query will restrict the s_id value to be greater than zero.
Example using CHECK constraint at Column Level
ALTER table Student add CHECK(s_id > 0);