Пример реализации приложения Программа отправки и анализа SMS-сообщений (через e-mail с WEB-интерфейсом.

Slides:



Advertisements
Similar presentations
Data Definition and Integrity Constraints
Advertisements

Using DDL Statements to Create and Manage Tables
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
More SQL Data Definition
POSTGRESQL DUNGEON WITH TABLE INHERITANCE AND CONSTRAINTS Edel Sherratt.
Complex Integrity Constraints in SQL. Constraints over a Single Table Table Constraint: Create TABLE Sailors (sid INTEGER, sname CHAR(10), rating INTEGER,
1 I Esempio di constraints. 2 DROP TABLE regions; CREATE TABLE regions ( region_id NUMBER CONSTRAINT region_id_nn NOT NULL, region_name VARCHAR2(25) );
AN INTRODUCTION TO PL/SQL Mehdi Azarmi 1. Introduction PL/SQL is Oracle's procedural language extension to SQL, the non-procedural relational database.
MySQL-Database Teppo Räisänen Oulu University of Applied Sciences School of Business and Information Management.
NMED 3850 A Advanced Online Design February 25, 2010 V. Mahadevan.
Murali Mani SQL DDL and Oracle utilities. Murali Mani Datatypes in SQL INT (or) INTEGER FLOAT (or) REAL DECIMAL (n, m) CHAR (n) VARCHAR (n) DATE, TIME.
SQL Keys and Constraints Justin Maksim. Key Declaration Key constraint defined within the CREATE TABLE command Key can be declared using either the PRIMARY.
SQL DDL constraints Restrictions on the columns and tables 1SQL DDL Constraints.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Phonegap Bridge – File System CIS 136 Building Mobile Apps 1.
Sage CRM Developers Course
Database Systems Lecture 5 Natasha Alechina
SQL Basics. SQL SQL (Structured Query Language) is a special-purpose programming language designed from managing data in relational database management.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
ORACLE SQL. Overview Personal DBMS Vs Client/Server DBMS Oracle 8 Environment SQL – syntax and examples PL/SQL-introduction.
CS450 HW2Page 1 Homework #2  Due the midnight of April 15th.  100 Points  In this homework, you create an SQL script to build the MOVIES database according.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Virtual Private Databases Dr. Gabriel. 2 Overview of Virtual Private Databases A VPD deals with data access VPD controls data access at the row or column.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
SQL Server 7.0 Maintaining Referential Integrity.
Introduction to MySQL Lab no. 10 Advance Database Management System.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
CSC 405: Web Application And Engineering II9.1 Web programming using PHP What have we learnt? What have we learnt? Sending s using PHP Sending s.
Procedure Function Trigger. create table employee ( id number, name varchar2(100), deptno number, salary float, primary key(id) ) create table deptincrease.
SQL Basics. 5/27/2016Chapter 32 of 19 Naming SQL commands are NOT case sensitive SQL commands are NOT case sensitive But user identifier names ARE case.
SQL: DDL. SQL Statements DDL - data definition language –Defining and modifying data structures (metadata): database, tables, views, etc. DML - data manipulation.
Ingres 2006 release 2 ANSI date/time data types Derived Tables.
Хранимые процедуры PL/plPgSQL. Общий вид [ DECLARE declarations ] BEGIN statements END.
Creating Tables and Inserting Records -- Not easy to edit! -- check constraints! Create table test1 ( C1 char(5) primary key, C2 Varchar2(15) not null.
Using the Table API. Standard Uses of API Populate Columns via Sequences Insert Default Values instead of nulls Populate Autogen Columns –Date Created,
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Dec 8, 2003Murali Mani Constraints B term 2004: lecture 15.
1 SQL - II Data Constraints –Applying data constraints Types of data constraints –I/O constraints The PRIMARY KEY constraints The FOREIGN KEY constraints.
7 1 Constraints & Triggers Chapter Constraints and triggers? Constraints: Certain properties that the DBMS is required to enforce –E.g. primary.
SQL introduction 2013.
Visual Programing SQL Overview Section 1.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Creating A Database Driven Website 1.Setting Up Your Web Server 2.Creating a Database 3.Creating a Webpage to Display Information From a Database 4.Creating.
CSC 405: Web Application Engineering II9.1 Web programming using PHP What have we learnt? What have we learnt? Sending s using PHP Sending s.
Learningcomputer.com SQL Server 2008 –Views, Functions and Stored Procedures.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Including Constraints. What Are Constraints? Constraints enforce rules at the table level. You can use constraints to do the following: – Enforce rules.
Constraints Review. What is a constraint? Unique – forbids duplicate values Referencial – Foreign key Check Constraint – sets restrictions on data added.
1 Announcements Reading for next week: Chapters 6 and 7  Next-to-Last reading from the text for a little while (I promise) Your database accounts should.
SQL constrains and keys. SORTED RESULTS Sort the results by a specified criterion SELECT columns FROM tables WHERE predicates ORDER BY column ASC/DESC;
Working with MySQL A290/A590, Fall /07/2014.
1 CSE 4904 Core Database Classes. 2 CSE 4904 The User Table CREATE TABLE `tmr`.`user` ( `USER_ID_PK` int(11) NOT NULL AUTO_INCREMENT, `UserName` varchar(25)
MS SQL Create Table Cust USE jxc00 GO CREATE TABLE cust ( cust_id smallint IDENTITY(1,1) NOT NULL, cust_name char(10)
Big Data Yuan Xue CS 292 Special topics on.
IS232 Lab 9. CREATE USER Purpose: Use the CREATE USER statement to create and configure a database user, which is an account through which you can log.
The Basics of Data Manipulation
Database Keys and Constraints
Referential Integrity MySQL
Lecturer: Mukhtar Mohamed Ali “Hakaale”
The Basics of Data Manipulation
For student, require values for name and address.
DATABASE SQL= Structure Query Language مبادئ قواعد بيانات
SQL Code for Byrnetube video
Rob Gleasure robgleasure.com
Data Definition Language
Instructor: Samia arshad
កម្មវិធីបង្រៀន SQL Programming ជាភាសាខ្មែរ Online SQL Training Course
SQL NOT NULL Constraint
SQL AUTO INCREMENT Field
Presentation transcript:

Пример реализации приложения Программа отправки и анализа SMS-сообщений (через с WEB-интерфейсом.

Состав программного комплекса Скрипт для создания серверной части(SQL) Интерфейс пользователя (HTML) Скрипт для отправки сообщений с занесением в базу данных(ASP) Скрипт для анализа сообщений и отправки предупреждений(ASP)

Скрипт для создания серверной части(SQL) CREATE TABLE T_WORDS ( KEY varchar(50) NOT NULL ); INSERT INTO T_WORDS VALUES ('bomba'); INSERT INTO T_WORDS VALUES ('terror');

T_USERS CREATE TABLE T_USERS ( N_ID_USER int NOT NULL PRIMARY KEY, C_ varchar(50) NOT NULL, C_TELEFON varchar(50) NOT NULL, N_COUNT_ERR int, CONSTRAINT CK_ CHECK > 0 ) );

T_SMS CREATE TABLE T_SMS ( N_ID_SMS int NOT NULL PRIMARY KEY, N_ID_USER int NOT NULL FOREIGN KEY referehces T_USERS(N_ID_USER), D_DATE_SMS date NOT NULL DEFAULT (TODATE()), C_ORIG_TELEFON varchar(50) NOT NULL, C_DEST_TELEFON varchar(50) NOT NULL, C_MESSAGE varchar(160) );

Создание последовательностей CREATE SEQUENCE SEQ_USERS INCREMENT BY 1 START WITH 1 ; CREATE SEQUENCE SEQ_SMS INCREMENT BY 1 START WITH 1 ;

Создание представления CREATE OR REPLACE VIEW BAD_USERS ( , TELEFON, COUNT_SMS, COUNT_BAD ) AS SELECT C_ , C_TELEFON, COUNT(*), N_COUNT_ERR FROM T_USERS, T_SMS WHERE T_USERS.N_ID_USER = T_SMS.N_ID_USER AND N_COUNT_ERR > 0 GROUP BY C_ , C_TELEFON, N_COUNT_ERR HAVING COUNT(*) > 1;

Функция вставки нового user (или изменения параметров старого) CREATE OR REPLACE FUNCTION INS_USER ( varchar2,TELEFON varchar2, SMS varchar2) RETURN int IS count_bad int; # кол-во плохих слов n_usr int; # номер юзера BEGIN

Текст функции --Вычисляем наличие плохих слов в sms SELECT COUNT(*) into count_bad FROM T_WORDS WHERE INSTR(KEY,SMS)>0;

Ищем этого юзера в базе -- В n_usr будет кол-во юзеров с таким мылом SELECT count(*) into n_usr FROM T_USERS WHERE C_ = ;

Вставляем или обновляем информацию о юзере IF n_usr > 0 THEN UPDATE T_USERS SET N_COUNT_ERR = N_COUNT_ERR + count_bad WHERE C_ = ; -- Нет еще такого юзера в списке ELSE INSERT INTO T_USERS(N_ID_USER,C_ ,C_TELEFON,N_COUNT_ERR) VALUES (SEQ_USERS.nextval, , TELEFON, count_bad); END IF;

Возвращаем номер юзера SELECT N_ID_USER into n_usr FROM T_USERS WHERE C_ = ; RETURN n_usr; END;

Процедура вставки сообщения в базу CREATE OR REPLACE PROCEDURE NEW_SMS( varchar2, TELEFON1 varchar2, TELEFON2 varchar2, SMS varchar2) IS n_usr int; BEGIN n_usr := INS_USER( , telefon1, sms); INSERT INTO T_SMS(N_ID_SMS, N_ID_USER, C_ORIG_TELEFON,C_DEST_TELEFON, C_MESSAGE) VALUES (SEQ_SMS.nextval,n_usr,TELEFON1,TELEFON2, SMS); END;

Интерфейс пользователя Отправка SMS-сообщений через почту Введите ваш Введите ваш пароль для Введите ваш номер телефона: Введите номер телефона-получателя: Введите ваше сообщение:

Скрипт для отправки сообщений send sms <% = Request.Form(" "); pass = Request.Form("pass"); tel1 = Request.Form("telefon1"); tel2 = Request.Form("telefon2"); sms = Request.Form("sms");

objCon = Server.CreateObject("ADODB.Connection"); objCon.Open("intranet", "iren", "iren40"); Server.ScriptTimeout = 1800; cSQL = "begin NEW_SMS('"+ +"', '"+tel1+"', '"+tel2+"', '"+sms+"'); end;"; Response.write(cSQL); objCon.Execute(cSQL);

Set SMS = Server.CreateObject("SMS_Gateway.clsSMS_Gateway") x = SMS.Send_SMS( , pass,tel1, tel2, sms) objCon.Close(); Set SMS = Nothing; %>

Скрипт выводит в окно браузера список «плохих» юзеров send sms <%

Получаем список objCon = Server.CreateObject("ADODB.Connection"); objCon.Open("intranet", "iren", "iren40"); Server.ScriptTimeout = 1800; cSQL = ""; cSQL = cSQL + " select , TELEFON, COUNT_SMS, COUNT_BAD "; cSQL = cSQL + " FROM BAD_USERS " ; cSQL = cSQL + " ORDER BY COUNT_BAD DESC " ; RecSet = Server.CreateObject("ADODB.RecordSet"); RecSet.Open(cSQL, objCon, 3);

Выводим список while (!RecSet.EOF) { Response.write('Пользователь:' + RecSet(" ") ); R esponse.write('['+RecSet("TELEFON")+']'); Response.write(' проколов: '+ RecSet("COUNT_BAD")); Response.write(' сообщений :'+ RecSet("COUNT_SMS")); RecSet.MoveNext(); } %>

Текст предупреждения Рассылка всем предупреждений Текст предупреждения: <% RecSet.Close(); objCon.Close(); %>