Home Database Mysql Tutorial 数据库课程设计--“茶咖啡”销售管理系统总结

数据库课程设计--“茶咖啡”销售管理系统总结

Jun 07, 2016 pm 04:12 PM
Summarize database management system design course Sale

为期一周的数据库课程设计终于完工, 总结一些经验和教训。发现基础的知识还是要时刻记在心中,知识不基础,何谈去开发?因为做什么东西都首先要一定的目标,计划,以及做到东西要做到那个程度,这方面一点要先在脑子里有一个印象,然后才能用所学的知识点去

为期一周的数据库课程设计终于完工, 总结一些经验和教训。发现基础的知识还是要时刻记在心中,知识不基础,何谈去开发?因为做什么东西都首先要一定的目标,计划,以及做到东西要做到那个程度,这方面一点要先在脑子里有一个印象,然后才能用所学的知识点去发挥, 因此知识点一点要掌握牢固,自己在设计课程设计的过程中,发现写好的数据库语言一点运行,就会出现这个那个的问题。然后从头去寻找问题的源头,才发现表的主键和外键设置出了问题。然后琢磨半天,突然意识到到底是什么主键和外键?

两个的定义和作用到底是什么?,这才发现以前上课所学的知识现在非所用,知其然不知其所以然。

 

键:唯一标识表中的所有行的一个列或一组列。
主键不允许空值。不能存在具有相同的主键值的两个行,因此主键值总是唯一标识单个行。
表中可以有不止一个键唯一标识行,每个键都称作候选键。只有一个候选键可以选作表的主键,所有其它候选键称作备用键。尽管表不要求具有主键,但定义主键是很好的做法。
外键(FK): 是用于建立和加强两个表数据之间的链接的一列或多列。通过将保存表中主键值的一列或多列添加到另一个表中,可创建两个表之间的链接。这个列就成为第二个表的外键。
例如:成绩表中的学号不能做成绩表的主键(因为一个学生可以有多行成绩数据),但每行的学号和学生表中的学号相对应,并且学生表中的学号是学生表的主键,则称成绩表中的学号是学生表的外键。(典型的一对多关系)

写SQL语言还出现了这几种情况:

(1)创建一个新表的时候,把英文括号写成了中文,找错误找了半小时。

(2)新表第一次录入数据之后,第二次不能再次录入,已经造成重复。

(3)没有注意主键不能为空值。

(4)外键设置时约束项没有搞清楚。

 

通过这次课程设计发现这其中需要的很多知识我们没有接触过,上网查找资料的时候发现我们以前所学到的仅仅是皮毛,还有很多需要我们掌握的东西我们根本不知道。同时也发现有很多已经学过的东西我们没有理解到位,不能灵活运用于实际,不能很好的用来解决问题,这就需要自己不断的大量的实践,通过不断的自学,不断地发现问题,思考问题,进而解决问题。在这个过程中我们将深刻理解所学知识,同时也可以学到不少很实用的东西。

 

CREATE TABLE BILL
(
   BILL_num  char(10)   primary key ,
   BILL_time  char(8)    NOT NULL,
   BILL_paymoney  char(10)  NOT NULL,
   BILL_summoney char(10)   NOT NULL,
   BILL_goodstype  char(10)     NOT NULL,
   BILL_unitprice char (10)  NOT NULL,
   Customers_num char  (10),
   MemberID char (11) ,
)
CREATE TABLE Member
(
MemberID char(11) primary key,
MemberNAme char(10)  NOT NULL,
MemberSex char (2)  NOT NULL,
Memberphone varchar(12)  NOT NULL,
BILL_num char(10) NOT NULL, 
constraint MemberSex check(MemberSex='男'or MemberSex='女'),
foreign key (BILL_num ) references BILL(BILL_num)
)
CREATE TABLE Customers

(
   Customers_num char  (10) primary key  ,
   Customers_name char (10)  NOT NULL,
   BILL_num char(10) NOT NULL,
   foreign key (BILL_num ) references BILL(BILL_num)
)
CREATE TABLE Goods
(    
   Goods_num char(4) primary key,
   Goods_name char (10) ,
   Goods_stock char(10),
   BILL_num char(10),
   foreign key (BILL_num ) references BILL(BILL_num)
)
go
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID,Customers_num)
values('2014010101','20140101','100','50','蓝山','30','20140101001','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID ,Customers_num)
values('2014010102','20140101','100','50','炭烧','35','20140202002','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID,Customers_num )
values('2014010103','20140101','100','50','美式','40','20140310003','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID ,Customers_num)
values('2014010104','20140101','100','50','拿铁','45','20140404004','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID ,Customers_num)
values('2014010105','20140101','100','50','摩卡','50','20141001005','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID, Customers_num)
values('2014010106','20140101','100','50','卡布奇诺','55','20141101006','Null')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID, Customers_num)
values('2013010101','20140101','100','50','卡布奇诺','55','Null','2014110106')
insert  into  BILL(BILL_num, BILL_time,BILL_paymoney ,BILL_summoney, BILL_goodstype ,BILL_unitprice ,MemberID, Customers_num)
values('2013010102','20140101','100','50','卡布奇诺','55','Null','2014110106')

insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num) 
values ('20140101001','李一','男','15832578651','2014010101')
insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num) 
values ('20140202002','李二','女','15832578652','2014010102')
insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num) 
values ('20140310003','李三','男','15832578653','2014010103')
insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num) 
values ('20140404004','李四','女','15832578654','2014010104')
insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num) 
values ('20141001005','李五','男','15832578655','2014010105')
insert  into Member(MemberID,MemberNAme,MemberSex,Memberphone,BILL_num)
values ('20141101006','李六','女',【本文来自鸿网互联 (http://www.68idc.cn)】'15832578656','2014010106')

insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('1','蓝山','10','2014010101')                                                    
insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('2','炭烧','10','2014010102')
insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('3','美式','10','2014010103')
insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('4','拿铁','10','2014010104')
insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('5','摩卡','10','2014010105')
insert  into Goods(Goods_num ,Goods_name ,Goods_stock ,BILL_num )
values('6','卡布奇诺','10','2014010106')

insert  into Customers( Customers_num,Customers_name,BILL_num )
values ('01','王一','2013010101')
insert  into Customers( Customers_num,Customers_name,BILL_num )
values ('02','王二','2013010102')



Copy after login
实验结果:会员信息:

 

\

商品信息:

\

顾客信息:

\

账单信息:

\

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Retro trend! HMD and Heineken jointly launch flip phone: transparent shell design Retro trend! HMD and Heineken jointly launch flip phone: transparent shell design Apr 17, 2024 pm 06:50 PM

According to news on April 17, HMD teamed up with the well-known beer brand Heineken and the creative company Bodega to launch a unique flip phone - The Boring Phone. This phone is not only full of innovation in design, but also returns to nature in terms of functionality, aiming to lead people back to real interpersonal interactions and enjoy the pure time of drinking with friends. Boring mobile phone adopts a unique transparent flip design, showing a simple yet elegant aesthetic. It is equipped with a 2.8-inch QVGA display inside and a 1.77-inch display outside, providing users with a basic visual interaction experience. In terms of photography, although it is only equipped with a 30-megapixel camera, it is enough to handle simple daily tasks.

ZTE 5G portable Wi-Fi U50S goes on sale for NT$899 at first launch: top speed 500Mbps ZTE 5G portable Wi-Fi U50S goes on sale for NT$899 at first launch: top speed 500Mbps Apr 26, 2024 pm 03:46 PM

According to news on April 26, ZTE’s 5G portable Wi-Fi U50S is now officially on sale, starting at 899 yuan. In terms of appearance design, ZTE U50S Portable Wi-Fi is simple and stylish, easy to hold and pack. Its size is 159/73/18mm and is easy to carry, allowing you to enjoy 5G high-speed network anytime and anywhere, achieving an unimpeded mobile office and entertainment experience. ZTE 5G portable Wi-Fi U50S supports the advanced Wi-Fi 6 protocol with a peak rate of up to 1800Mbps. It relies on the Snapdragon X55 high-performance 5G platform to provide users with an extremely fast network experience. Not only does it support the 5G dual-mode SA+NSA network environment and Sub-6GHz frequency band, the measured network speed can even reach an astonishing 500Mbps, which is easily satisfactory.

Honor Magic V3 debuts AI defocus eye protection technology: effectively alleviates the development of myopia Honor Magic V3 debuts AI defocus eye protection technology: effectively alleviates the development of myopia Jul 18, 2024 am 09:27 AM

According to news on July 12, the Honor Magic V3 series was officially released today, equipped with the new Honor Vision Soothing Oasis eye protection screen. While the screen itself has high specifications and high quality, it also pioneered the introduction of AI active eye protection technology. It is reported that the traditional way to alleviate myopia is "myopia glasses". The power of myopia glasses is evenly distributed to ensure that the central area of ​​​​sight is imaged on the retina, but the peripheral area is imaged behind the retina. The retina senses that the image is behind, promoting the eye axis direction. grow later, thereby deepening the degree. At present, one of the main ways to alleviate the development of myopia is the "defocus lens". The central area has a normal power, and the peripheral area is adjusted through optical design partitions, so that the image in the peripheral area falls in front of the retina.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

New stacking process! Xiaomi MIX Fold 4 is equipped with Jinshajiang 'three-dimensional special-shaped' battery for the first time New stacking process! Xiaomi MIX Fold 4 is equipped with Jinshajiang 'three-dimensional special-shaped' battery for the first time Jul 20, 2024 am 03:20 AM

According to news on July 19, Xiaomi MIX Fold 4, the first flagship folding new phone, was officially released tonight and is equipped with a "three-dimensional special-shaped battery" for the first time. According to reports, Xiaomi MIX Fold4 has achieved a major breakthrough in battery technology and designed an innovative "three-dimensional special-shaped battery" specifically for folding screens. Traditional folding screen devices mostly use conventional square batteries, which have low space utilization efficiency. In order to solve this problem, Xiaomi did not use the common winding battery cells, but developed a new lamination process to create a new form of battery, which greatly improved the space utilization. Battery Technology Innovation In order to accurately alternately stack positive and negative electrode sheets and ensure the safe embedding of lithium ions, Xiaomi has developed a new ultrasonic welding machine and lamination machine to improve welding and cutting accuracy.

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

Vivo's phone with the strongest signal! vivo X100s is equipped with a universal signal amplification system: 21 antennas, 360° surround design Vivo's phone with the strongest signal! vivo X100s is equipped with a universal signal amplification system: 21 antennas, 360° surround design Jun 03, 2024 pm 08:41 PM

According to news on May 13, vivoX100s was officially released tonight. In addition to excellent images, the new phone also performs very well in terms of signal. According to vivo’s official introduction, vivoX100s uses an innovative universal signal amplification system, which is equipped with up to 21 antennas. This design has been re-optimized based on the direct screen to balance many signal requirements such as 5G, 4G, Wi-Fi, GPS, and NFC. This makes vivoX100s the mobile phone with the strongest signal reception capability in vivo’s history. The new phone also uses a unique 360° surround design, with antennas distributed around the body. This design not only enhances the signal strength, but also optimizes various daily holding postures to avoid problems caused by improper holding methods.

See all articles