`
superyang
  • 浏览: 22833 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论
阅读更多
package util;

import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BaseTest {

	/**
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		// System.out.println(HibernateSessionFactory.getSession().toString());
		char ch[] = new char[26];
		String arr[] = new String[25];
		int j = 0;
		for (int i = 97; i < 98 + 25; i++) {
			ch[j] = (char) i;

			j++;
		}
		for (int i = 1; i <= 2; i++) {
			File f = new File("D:/群发用户/邮件群发用户--"
					+ new SimpleDateFormat("yyyy-MM-dd").format(new Date())
					+ "--" + i + ".txt");
			f.createNewFile();
			FileOutputStream out = new FileOutputStream(f);
			OutputStreamWriter w = new OutputStreamWriter(out);
			if (i == 1) {

				w.write("domain:aiwow.cc" + "\r\n");
				for (int k = 1; k <= 25; k++) {
					String str = "";
					for (int r = 1; r <= 5; r++) {
						int index = (int) (Math.random() * 25);
						str += ch[index];
					}
					arr[k - 1] = str;
					w.write(str + ",123456,爱我网" + "\r\n");

				}

			} else {

				for (int k = 1; k <= 25; k++) {

					String temp = arr[k - 1];
					w.write("Y," + temp + "@aiwow.cc," + temp
							+ "@aiwow.cc,123456,127.0.0.1,25,N" + "\r\n");

				}
			}

			w.close();
			out.close();

		}
		System.out.println("文件生成成功.....");

	}
}


	<!--  -->
		<div id="go_active" style="width:100%;height:60px;position:absolute;display:none;">
			<div style="margin:0px auto; width:968px;">
				<iframe frameborder="0" 
					style="position:absolute;top:1px;z-index:0; solid #000; height: 60px;width:968px;; _height: 60px; _width: 968px;background-color: #fff;"></iframe>
				<div style="position:absolute;">
					<a href="http://www.aiwow.cc/activity/huodong.html" target="_blank">
					<img src="/images/go_active.jpg" /></a>
				</div>	
				<div  style="top:1px;width:968px;text-align:right;position:absolute;">
							<a href="javascript:void(0);" onclick="noDis('go_active');"><img src="/user/images/lwx-gb.jpg" width="59" height="23" /></a>
			 	</div>
			</div>	
		</div>
		<!-- 束-->





var tr;
tr = table.insertRow(0);
tr.height=25;
tr.onclick=function(){
 alert("tr created!")
}

var cellFuncs = [
     function(data) {
      return data.replyDate;
     } ];
   DWRUtil.addRows(
       'lines',
       tempList,
       cellFuncs,
       {
        rowCreator : function(options) {
         var row = document.createElement("tr");

//鼠标移动到行上面,背景色和行高改变

row.onmouseover = function(){this.style.backgroundColor='#DEDFDE';this.style.height='26';}
row.onmouseout = function(){this.style.backgroundColor='#ffffff';this.style.height='25';}

//设定行的其他样式
row.setAttribute("height","25" );
row.setAttribute("bgcolor","#ffffff" );
row.setAttribute("align","center" );
row.setAttribute("style","" );
row.style.backgroundColor = "#ffffff";
         return row;
        },

        cellCreator : function(options) {
         var td = document.createElement("td");
         var index = options.cellNum;
         if (index == 0) {
          td.height = "25";
         }
         return td;
        },
        escapeHtml :false
       });

cell1.attachEvent("onmouseover",onover); //单元格插入onmouseover事件   





自己对sql的理解。用一句俗话说:人有七窍,已经通了六窍,有没有童鞋指点一下

问:关系模式:User(userId, userName), Article(articleId, userId, title,   content),Vote(articleId, score),User为用户关系,Article为用户发表的文章关系,Vote为文章得票关系,title为文章标题、score为得票数。
(1)用SQL语言查询所有没发表过文章的用户名;
(2)用SQL语言查询得票数大于100的所有文章标题,按得票数倒序排列;
(3)用SQL语言查询出发表文章数大于5,文章平均得票数大于100的用户名,按平均得票数倒序排列;
(4)设计这些表的主键、外键和索引,并指出上面三个查询所使用的索引。
(5)当用户数超过1000万,文章数超过1亿时,如何考虑存储及性能的改进和优化? 

 

答: 

 

1 select * from User where useid  not in(select userid from Article);
2 select title from article   inner  join vote  on article.articleid=vote.aritcleid and  vote.score>100 order by vote.score asc; 
3有点不太会,下面胡乱乱写了一通

3 select * from user where userid in(select userid from Article inner join vote on article.articleid = vote.articleid group by userId  having avg(score)>100) group by userid having count(*) >5;

4主键外键应该很简单,索引第一个应该是userid,第二个是articleid 和score,第三个应该是articleid和 userid

5用户数按照id分割分布式存储,文章类似,还可以用读写分离等策略水平扩展数据库.

分享到:
评论
1 楼 yongsky 2011-02-24  
第一个可以不用in,这样写,select user.*,Article.userid  from user left join Article where Article.userid is null;
第三个可以用几个嵌套查询实现。

相关推荐

Global site tag (gtag.js) - Google Analytics