35-Blog Site Database-Blog Information Data Operation

35-Blog Site Database-Blog Information Data Operation (2)

Item Description

Nowadays, micro-blog and blog publishing information have become the main information publishing and dissemination system. How to manage these data, this project mainly operates on the classified information table and blog information table of blog website.

The blog site database operation requirements are as follows:

1) Create a database BlogDB.

2) Create categories of the classification information table as shown in table J2-35-1.

Table J2-35-1 categories table

Field nameField Descriptiondata typeAllow blankRemarks
CategoryIDClassification IDintegernoPrimary key, self-increasing (increment 1)
CategoryNameCategory nameCharacters (20)no
ArticlesNumNumber of Category Articlesintegerno

3) Create a blog information table article with the table structure as shown in Table J2-35-2.

Table J2-35-2 article table

Field nameField Descriptiondata typeAllow blankRemarks
IDArticle IDintegernoPrimary key, self-increasing (increment 1)
C_IDClassification IDintegernoforeign key
TitleArticle TitleCharacters (100)no
ContentcontentText Typeyes
CommentsNumNumber of commentsintegerno
PostdateDate of publicationDate Timeno

4) An association is established between the two tables, and the C_ID of the article is associated with the CategoryID of the categories.

5) Table categories basic data as shown in J2-35-3.

Table J2-35-3 Catgories table base data

CategoryIDCategoryNameArticlesNum
1History2
2science and technology1
3Military3
4Journalism8
5Travel?2
6Software Download9

6) Table article basic data is shown in table J2-35-4.

Table J2-35-4 article table base data

IDC_IDTitleContentCommentsNumPostdate
14Why do students faint in military training?Recently, at the National Symposium on Sports Work in Universities held by Nankai University, Wang Dengfeng, Director of Sports Health and Art Education Department of the Ministry of Education and Secretary-General of the Organizing Committee of the Ninth Universiade, listed an astonishing number: Half a month ago, when he attended the closing ceremony of Class 2011 students'military training at Peking University, he learned that during the two-week military training period, nearly 3500 students saw more than 6000 medical visits cumulatively.Especially in the first week, many people fainted. Wang Dengfeng revealed that in order to make up for the weakness of school sports, China will incorporate students'physique into the evaluation system of colleges and universities. (China Radio Network, September 17)02011-7-2
22Can we solve the Boy Crisis by postponing enrollment?"In view of the different speed of intellectual development of boys and girls, boys are generally later than girls by about 2 years, and there are differences in mental development between same-sex students, so it is against the law of education to uniformly stipulate that boys and girls can enter school at the age of 7. It is suggested that girls can enter school at the age of 67 and boys can enter school at the age of 78. Now girls are generally enrolled in universities higher than boys, so it is necessary to reflect."On September 24, Professor Wu Bihu of Peking University made a public comment on Sina Weibo that boys should attend school later than girls. (Modern Express September 27)12011-8-3
34A letter of admission from a foreign university is nothingRecently, a resignation letter from Dayle Smith, vice president of the Business School of the University of San Francisco, poured cold water on China's study abroad. According to the San Francisco Chronicle on September 23, Weber, director of the Business School, said in a letter to employees that Smith's resignation was due to a "substantial increase" in foreign students."Given the large number of students with poor English proficiency and unbalanced student-origin ratios, we will face some unique educational and cultural challenges." However, students with poor English proficiency are enrolled due to the "Conditional Enrollment" policy.82011-9-4
46Universities don't aspire to be "top universities"California Polytechnic Institute ranked first in 2012-2013, while Harvard University ranked second in last year dropped to fourth. Peking University rose from 49 last year to 46, Tsinghua University rose 19, 71 to 52, and Hong Kong University of Science and Technology both ranked lower than last year.35 and 65. (China News Network, October 5)22011-8-23

(1) Task description

Task 1: Create blog site database BlogDB in SQL language

1) The primary database file has an initial value of 10MB and a maximum of 20MB, increasing by 1MB.

2) The initial value of the log file is 5MB, up to 10MB, increasing by 10%.

IF DB_ID('BlogDB') IS NOT NULL DROP DATABASE BlogDB
GO
CREATE DATABASE BlogDB
ON PRIMARY
(
	NAME=BlogDB,
	FILENAME='D:\xxxx\BlogDB.mdf',
	SIZE=10MB,
	MAXSIZE=20MB,
	FILEGROWTH=1MB
)
LOG ON
(
	NAME=BlogDB_log,
	FILENAME='D:\xxxx\BlogDB_log.ldf',
	SIZE=5MB,
	MAXSIZE=10MB,
	FILEGROWTH=10%
)

Task 2: Create classified information table categories, blog information table article in SQL language

1) Create database tables according to the provided table J2-35-1, J2-35-2 structure, with primary and foreign keys.

CREATE TABLE categories
(
	CategoryID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
	CategoryName NVARCHAR(20) NOT NULL,
	ArticlesNum INT NOT NULL,
)
CREATE TABLE article
(
	ID INT NOT NULL PRIMARY KEY IDENTITY(1,1),
	C_ID INT NOT NULL,
	Title NVARCHAR(100) NOT NULL,
	Content TEXT,
	CommentsNum INT NOT NULL,
	Postdate DATETIME NOT NULL,
	FOREIGN KEY(C_ID) REFERENCES categories(CategoryID)
)

Task 3: Operate classified information table categories, blog information table article s in SQL language

1) Add data to the table according to the data provided in tables J2-35-3 and J2-35-4.

2) Statistics the number of Posts based on table categories.

3) Delete the Software Download category and its blogs.

INSERT INTO categories VALUES('History',2),('science and technology',1),('Military',3),('Journalism',8),('Travel?',2),('Software Download',9)

INSERT INTO article VALUES(4,'Why do students faint in military training?','Recently, at the National Symposium on Sports Work in Universities held by Nankai University, Wang Dengfeng, Director of Sports Health and Art Education Department of the Ministry of Education and Secretary-General of the Organizing Committee of the Ninth Universiade, listed an astonishing number: Half a month ago, when he attended the closing ceremony of Class 2011 students'military training at Peking University, he learned that during the two-week military training period, nearly 3500 students saw more than 6000 medical visits cumulatively.Especially in the first week, many people fainted. Wang Dengfeng revealed that in order to make up for the weakness of school sports, China will incorporate students'physique into the evaluation system of colleges and universities. (China Radio Network September 17)',0,'2011-7-2'),
(2,'Can we solve the Boy Crisis by postponing enrollment?','"In view of the different speed of intellectual development between boys and girls, boys are generally later than girls by about 2 years, and there are also differences in mental development between same-sex children. Therefore, it is universally stipulated that boys and girls at the age of 7 should go to school in violation of the law of education.~7 Enrollment at age 7 for boys~8 On September 24, Professor Wu Bihu of Peking University made a public comment on Sina Weibo that boys should enter school later than girls.(Modern Express September 27)',1,'2011-8-3'),
(4,'A letter of admission from a foreign university is nothing','Recently, Dell, associate dean of the University of San Francisco Business School·Smith(Dayle Smith)According to the San Francisco Chronicle on September 23, Weber, director of Business School, said in a letter to employees that Smith's resignation was due to a "substantial increase" in foreign students. Smith wrote:"Given the large number of students with poor English proficiency and unbalanced student-origin ratios, we will face some unique educational and cultural challenges." However, students with poor English proficiency are enrolled due to the "Conditional Enrollment" policy.',8,'2011-9-4'),
(6,'Universities don't aspire to be "top universities"','UK Times Higher Education Special Issue released on March 3, 2012-2013 California Institute of Technology ranked first in the world, while Harvard University ranked second last year dropped to fourth. Peking University rose from 49 to 46, Tsinghua University rose 19, from 71 to 52, and Hong Kong University of Science and Technology fell from last year to 35 and 65, respectively. (China News Network October 5)',2,'2011-8-23')

UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='History')) WHERE CategoryName='History'
UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='science and technology')) WHERE CategoryName='science and technology'
UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='Military')) WHERE CategoryName='Military'
UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='Journalism')) WHERE CategoryName='Journalism'
UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='Travel?')) WHERE CategoryName='Travel?'
UPDATE categories SET ArticlesNum=(SELECT COUNT(*) FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='Software Download')) WHERE CategoryName='Software Download'
SELECT * FROM categories

DELETE FROM article WHERE C_ID=(SELECT CategoryID FROM categories WHERE CategoryName='Software Download')
DELETE FROM categories WHERE CategoryName='Software Download'

Keywords: Java Database Big Data

Added by rich1983 on Fri, 15 Oct 2021 19:29:27 +0300