Object-oriented database design and application of 04 - Operation and query data table

First, the purpose of the experiment

  1. In this study, the use of SQL code required to implement and master the record of OML operations, with emphasis on object-oriented OML sentence of further study and deeper grasp;
  2. On the basis of the experimental difficulties of understanding, namely: update object-oriented query tables, records, and then further expand and consolidate the rules of using SQL code sentence syntax. Performing composite fuzzy query conditions and query the same time, to be understood that a relational database and object-oriented database similarities and differences, in particular, relates to the use of the reference object field.

       

 

Second, the experimental content

Import experimental background:

The company has completed the data sheet integrity and security of the database object settings, it will be carried out relevant tests, but the test needs to be filled before data records some initialization of the system, so we'll be recording DML operations.

① update a single record. The "Ba Jin suit" from "recommended" product to "hot spots" of goods, needs to be done to change the status of the goods.

② update multiple records. Discount on all merchandise now adjusted to 0.8, and adjusted to all purchase date of October 1, 2010.

③ delete a single record. Product No. 040002 item has been sold out, and later do not consider re-purchase, need to clear information about the product in the product information table.

④ delete all records. Delete all messages in the user table.

⑤ use complex query conditions. Need to understand the product category 01, commodity price and product information on more than 2,500 yuan, and the title characters required to display the product number, product name, product category and price.

⑥ fuzzy query. I know a commodity product name contains "520" character, requests for access to the commodity product number, product name, product unit price and merchandise discounts.

 

 

 

Third, experimental platform

Software: WORD, Oracle

   

 

 

Fourth, the experimental procedures

① update a single record. The "Ba Jin suit" from "recommended" product to "hot spots" of goods, change the status.

Insert into RD_COMMODITY_TYPES (COMMODITY_TYPE_ID,STATUS,COMMODITY_TYPE) values ('0003','推荐','服装');

Insert into C##RD.RD_GOODS (GOOD_ID,DISCOUNT,GOODS,UNIT_PRICE,PURCHASE_DATE,GOOD_TYPE) values ('0003','0.85','劲霸西服',165,'2017-32-23', (select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0003'));select GOOD_ID,GOODS,deref(GOOD_TYPE),(select STATUS from RD_COMMODITY_TYPES where RD_COMMODITY_TYPES.COMMODITY_TYPE_ID='0003') from RD_GOODS where GOOD_TYPE=(select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0003');

select GOOD_ID,GOODS,deref(GOOD_TYPE),(select STATUS from RD_COMMODITY_TYPES where RD_COMMODITY_TYPES.COMMODITY_TYPE_ID='0003') from RD_GOODS where GOOD_TYPE=(select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0003');

 

update RD_COMMODITY_TYPES set STATUS='热点' where COMMODITY_TYPE_ID='0003';

select GOOD_ID,GOODS,deref(GOOD_TYPE),(select STATUS from RD_COMMODITY_TYPES where RD_COMMODITY_TYPES.COMMODITY_TYPE_ID='0003') from RD_GOODS where GOOD_TYPE=(select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0003');

 


  

② update multiple records. The discount on all merchandise was adjusted to 0.8, all of the purchase date adjusted October 1, 2010

select * from RD_GOODS;

update RD_GOODS set  DISCOUNT='0.80',PURCHASE_DATE='2010-10-01';

select * from RD_GOODS;

 


  

③ delete a single record. Product No. 040002 item has been sold out, clear information on the commodity in the commodity table.

update RD_GOODS set  GOOD_ID='040002' where GOODS='劲霸西服';

select * from RD_GOODS;

 

delete from RD_GOODS where GOOD_ID='040002';

select * from RD_GOODS;

 


  

④ delete all records. Delete all messages in the user table.

select * from RD_MEMBERS;

 

delete from RD_MEMBERS;

select * from RD_MEMBERS;

 


  

⑤ use complex query conditions. Need to understand the product category 01, commodity price and product information on more than 2,500 yuan, and the title characters required to display the product number, product name, product category and price.

update RD_COMMODITY_TYPES set COMMODITY_TYPE='02';

Insert into RD_COMMODITY_TYPES (COMMODITY_TYPE_ID,STATUS,COMMODITY_TYPE) values ('0004','推荐','01');

Insert into C##RD.RD_GOODS (GOOD_ID,DISCOUNT,GOODS,UNIT_PRICE,PURCHASE_DATE,GOOD_TYPE) values ('0004','0.8','直升飞机',165000,'2017-32-23', (select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0004'));

Insert into C##RD.RD_GOODS (GOOD_ID,DISCOUNT,GOODS,UNIT_PRICE,PURCHASE_DATE,GOOD_TYPE) values ('0005','0.95','520钢铁胶水',165,'2017-32-23', (select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0004'));

Insert into C##RD.RD_GOODS (GOOD_ID,DISCOUNT,GOODS,UNIT_PRICE,PURCHASE_DATE,GOOD_TYPE) values ('0006','0.45','华人牌手机',23450,'2017-32-23', (select ref(a) from RD_COMMODITY_TYPES a where COMMODITY_TYPE_ID='0004'));

select * from RD_GOODS;

 

select GOOD_ID "商品号", GOODS "商品名称",(select COMMODITY_TYPE from RD_COMMODITY_TYPES where RD_COMMODITY_TYPES.COMMODITY_TYPE='01') "商品类别", UNIT_PRICE "价格" from RD_GOODS where (select COMMODITY_TYPE from RD_COMMODITY_TYPES where RD_COMMODITY_TYPES.COMMODITY_TYPE='01')='01' and UNIT_PRICE > 2500;

 


  

⑥ fuzzy query. I know a commodity product name contains "520" character, requests for access to the commodity product number, product name, product unit price and merchandise discounts.

select * from RD_GOODS;

 

select GOOD_ID,GOODS,UNIT_PRICE,DISCOUNT from RD_GOODS where GOODS like'%520%';

 


  

 

 

6.3.5 Operating results

① update a single record

 

FIG single pre-update data 5-1

 

 

FIG single data update 5-2

 

 

② update multiple records

 

Figure 5-3 before updating a plurality of data

 

 

FIG. 5-4 pieces of updated data

 

 

 

 

 

③ delete a single record

 

Figure 5-5 before deleting a single record

 

 

Figure 5-6 delete a single record

 

 

 

 

 

④ delete all records

 

Figure 5-7 before deleting all records

 

 

Figure 5-8 after deleting all records

 

 

 

 

 

⑤ use complex query conditions

 

Figure 5-9 before complex query conditions

 

 

Figure 5-10 compound condition after inquiry

 

 

 

 

 

⑦ fuzzy query

 

Figure 5-11 fuzzy query ago

 

 

Figure 5-12 fuzzy queries

 

 

 

 

 

Six experimental summary

Through the experiment, and experience relevant summary harvest, can be divided into point summarized as follows:

  1. When this experiment using a composite query's criteria, based on past experience SqlServer, and use [] to surround the Chinese column name to live or to use "as 'Alias'," the way, the statement is still being given, but through the Internet to find some information, only to find, Oracle column alias to use the Chinese, "" enclosed in double quotation mark;
  2. Fuzzy query, the simple way is to use a wildcard character matching operation may "%" and "_", where%: represents any number of characters, including zero;  

          i _:. represents an arbitrary character. Once again review the relevant knowledge of SqlServer;

  1. For some operating requirements in this experiment, because there is no perfect test preparation or cross-matching of the most consistent, so the operation is performed, the data must be prepared in advance, which is why the experimental procedure in this experiment, the subject clearly You can use SQL to demand a complete, which cited a number of reasons for the;
  2. 本实验在操作和实验结果记录的过程中,都采用了对比的方法,以实验前和经过需求处理后进行对比,突出表现操作需求的实验效果;
  3. 经过本实验,利用SQL代码实现并初步掌握了记录的OML操作,对于面向对象OML句型的进一步学习和深层次掌握的实验重点,也有了一定的认识;
  4. 面向对象数据库没有关系型数据库的主、外键,从理论体系上来说,逻辑层面较为简化。但是经过本实验似乎才发现,在SQL操作层面,但凡涉及对象表参照来说,往往要比关系型数据库复杂些许。

Guess you like

Origin www.cnblogs.com/Raodi/p/12155611.html