数据库设计:解释这个模式(Database Design: Explain this schema)
充分披露...在这里试着狂热地学习更多关于数据库的知识,所以我正在努力,并试图从源头获得这个答案,但无济于事。
来自databaseanswers的Barry Williams已经发布了这个模式。
我试图了解此架构中地址表的拆分。 我清楚地知道Addresses表包含给定地址的细节。 Client_Addresses和Staff_Addresses表是我的最佳选择。
1)我理解如所示的主外键的使用,但我假设当使用这些外键时,在同一个表中没有常驻主键(在这种情况下为date_address_from)。 有人可以解释两者的推理,并说出这实际上是如何工作的吗?
2)为什么你会使用date_address_from作为主键而不是像client_address_id那样的PK? 如果某人在一天之内输入两个地址,他的设计会有冲突吗? 如果是,如果不是,那是什么?
3)沿着规范化的路线......因为date_address_from和date_address_to在Client_Addresses和Staff_Addresses表中都应该相同,所以这些字段只是不包含在主地址表中?
Full disclosure...Trying feverishly here to learn more about databases so I am putting in the time and also tried to get this answer from the source to no avail.
Barry Williams from databaseanswers has this schema posted.
I am trying to understand the split of address tables in this schema. Its clear to me that the Addresses table contains the details of a given address. The Client_Addresses and Staff_Addresses tables are what gets me.
1) I understand the use of Primary Foreign Keys as shown but I was under the assumption that when these are used you don't have a resident Primary Key in that same table (date_address_from in this case). Can someone explain the reasoning for both and put it into words how this actually works out?
2) Why would you use date_address_from as the primary key instead of something like client_address_id as the PK? What if someone enters two addresses in one day would there be conflicts in his design? If so or if not, what?
3) Along the lines of normalization...Since both date_address_from and date_address_to are the same in the Client_Addresses and Staff_Addresses table should those fields just not be included in the main Address table?
原文:https://stackoverflow.com/questions/4663366
最满意答案
您已为
http
协议设置了本地Tor实例的代理,但您使用https
与“check.torproject.org”进行通信。 尝试:print opener.open('http://check.torproject.org/').read()
You've set up a proxy to your local Tor instance for the
http
protocol, but you're usinghttps
to talk to "check.torproject.org". Try:print opener.open('http://check.torproject.org/').read()
相关问答
更多-
urllib2 HTTP错误429(urllib2 HTTP error 429)[2023-12-23]
从https://github.com/reddit/reddit/wiki/API : 许多默认的用户代理(如“Python / urllib”或“Java”)受到严格限制,以鼓励独特和描述性的用户代理字符串。 这也适用于常规请求。 提出请求时,您需要提供您自己的用户代理标题。 #TODO: change user agent string hdr = { 'User-Agent' : 'super happy flair bot by /u/spladug' } req = urllib2.Reques ... -
好吧,我没有完全解决“为什么”重定向不同,但我发现在哪里可以使用请求获取我的cookie。 我认为这两个库之间的区别与它们处理重定向的方式有关。 所以我检查了两个请求的历史记录。 对于那些像req.history一样简单的“请求”,但对于urllib2,我使用了这段代码: class MyHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): ...
-
谷歌搜索建议 (和Tor手册确认 )9051是Tor的默认控制端口。 实际代理默认在端口9050上运行,这是您需要使用的端口。 但是,Vidalia不使用默认端口,无需额外配置。 另一个问题是,urllib2默认无法使用SOCKS代理。 有关可能的解决方案,请参阅这两个 问题 Google search suggests (and Tor manual confirms) that 9051 is Tor's default control port. Actual proxy is running on ...
-
无论在哪种情况下,您都不必在重复的区域中重复上述操作。 from mechanize import Browser import time b = Browser() tried=0 while True: try: r=b.open('http://www.google.com/foobar') except (mechanize.HTTPError,mechanize.URLError) as e: tried += 1 if isinstance(e,mechan ...
-
使用tor作为SOCKS5代理与python urllib2或机械化(using tor as a SOCKS5 proxy with python urllib2 or mechanize)[2024-02-07]
见问题末尾。 import socks import socket def create_connection(address, timeout=None, source_address=None): sock = socks.socksocket() sock.connect(address) return sock socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9050) # patch the soc ... -
也许你的random.py上有一个random.py文件或模块,所以python在其中搜索random.Random (存在于python2.7上)。 Maybe you have a random.py file or module on your pythonpath so python search in it to find random.Random (that exists on python2.7).
-
请求确实是同步的。 问题只是评估表达式实际上并不打印它。 如果要查看值,必须明确使用print : import urllib2 user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' req = urllib2.Request('http://www.google.com') response = urllib2.urlopen(req) page_source = response.read() print page_source ...
-
Python使用urllib2启动请求时无法使用Tor检查(Python fails Tor check using urllib2 to initiate requests)[2023-07-16]
您已为http协议设置了本地Tor实例的代理,但您使用https与“check.torproject.org”进行通信。 尝试: print opener.open('http://check.torproject.org/').read() You've set up a proxy to your local Tor instance for the http protocol, but you're using https to talk to "check.torproject.org". Try ... -
我解决了一个问题。 如果有人感兴趣:只使用urllib3并创建HTTPConnectionPool()。 I solved a problem. If someone interested: just using urllib3 and creating HTTPConnectionPool().
-
import requests URL = "http://www.facebook.com' r = requests.get(URL, auth=('username','password')) source = r.text print source - - -更改 - - - import mechanize browser = mechanize.Browser() browser.set_handle_robots(False) cookies = mechanize.CookieJar() ...